推荐学习书目
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 · 3681 views
    This topic created in 2929 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
        1
    ebingtel  
       May 10, 2018
    有这种说法?
    meik2333
        2
    meik2333  
       May 10, 2018
    应该不会吧……要不试试 celery
    a132811
        3
    a132811  
       May 10, 2018
    试了下 os.system('ls -l') 没有问题啊!

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