推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
miniyao
V2EX  ›  Python

怎样在生产环境中(gunicorn 起多个进程),还能使用 os.system 或 subprocess 命令?

  •  
  •   miniyao · May 10, 2018 · 4111 views
    This topic created in 3107 days ago, the information mentioned may be changed or developed.
    本地开发环境中 os.system 和 subprocess 都是正常执行的,但是在生产环境中,gunicorn 起了多个 worker,os.system 和 subprocess 这样的任务就全失效了。

    怎样才能在 gunicorn 多进程的环境中,还能使用这种 fork 进程的 os.system 或 subprocess 命令?
    8 replies  •  2018-05-10 22:57:46 +08:00
    ebingtel
    ebingtel
    May 10, 2018
    1
    有这种说法?
    meik2333
    meik2333
    May 10, 2018
    2
    应该不会吧……要不试试 celery
    a132811
    a132811
    May 10, 2018
    3
    试了下 os.system('ls -l') 没有问题啊!

    你把日志打开看看,我的都有
    --log-file gun.log --capture-output
    julyclyde
    julyclyde
    May 10, 2018
    4
    不会失效
    wzwwzw
    wzwwzw
    May 10, 2018
    5
    要不试试 pool ?
    applehater
    applehater
    May 10, 2018
    6
    用个 pid 文件记录进程不让他重复启动就好
    @a132811
    @julyclyde gunicorn 多个 worker 会把子进程也启动多次
    julyclyde
    julyclyde
    May 10, 2018❤️1
    7
    @applehater 多次那是你没理解 gunicorn 是怎么运行的,那是你自己的问题
    param
    param
    May 10, 2018 via Android
    8
    不會失效,我也是這麼用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   968 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 18:50 · PVG 02:50 · LAX 10:50 · JFK 13:50
    ♥ Do have faith in what you're doing.