V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
alsoran1
V2EX  ›  Python

求问 gunicorn 不同的 work 进程中,能共享一个对象,然后主进程定期去更新这些对象吗?

  •  
  •   alsoran1 · 2018-01-29 14:01:15 +08:00 · 1610 次点击
    这是一个创建于 2283 天前的主题,其中的信息可能已经有所发展或是发生改变。
    3 条回复    2018-02-26 10:07:42 +08:00
    alsoran1
        1
    alsoran1  
    OP
       2018-01-29 14:13:35 +08:00
    因为这个对象构建起来代价太大,并且需要保持一致性
    tonghuashuai
        2
    tonghuashuai  
       2018-01-29 15:18:48 +08:00
    这个问题用其他的方案去解决代价应该会小一点……比如把你要共享的对象数据存到 redis 中
    sinly100
        3
    sinly100  
       2018-02-26 10:07:42 +08:00
    你的这个问题本质就是多进程之间共享数据,一般最简单的方法是通过外部存储共享,如 MongoDB、Redis
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   834 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:09 · PVG 05:09 · LAX 14:09 · JFK 17:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.