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
akmonde
V2EX  ›  Python

关于 celery 在 windows 下不能进行 time limit(超时限制)的解决办法

  •  
  •   akmonde · 2017-03-17 14:25:42 +08:00 · 3409 次点击
    这是一个创建于 2597 天前的主题,其中的信息可能已经有所发展或是发生改变。
    曾经在配置文件里设置了超时限制, CELERYD_TASK_SOFT_TIME_LIMIT ,本来在 Linux 下是能用的。

    当然,这里插一句,也曾经设置过 CELERY_TASK_RESULT_EXPIRES 和 CELERYD_TASK_TIME_LIMIT ,不过没起作用。

    后来因为某些原因,程序迁移到了 windows 下,结果发现报错如下:
    UserWarning: Soft timeouts are not supported: on this platform: It does not have the SIGUSR1 signal.&*

    查了下文档:
    http://docs.celeryproject.org/en/latest/userguide/workers.html#time-limits
    发现:
    "Time limits do not currently work on Windows and other platforms that do not support the SIGUSR1 signal."

    另外看了下,在 @app.task()这样的形式,去在括号里添加 timeout 和 time limit 之类的内容,据说也是不行的。

    那么问题来了,难道 windows 下 celery 无法设置超时么?如果必须在 win 下运行的话,有其他解决办法么?
    6 条回复    2018-12-27 08:42:58 +08:00
    GoTop
        1
    GoTop  
       2018-12-25 00:48:59 +08:00
    我也遇到这个问题了,请问你解决了没?
    akmonde
        2
    akmonde  
    OP
       2018-12-25 15:31:37 +08:00
    @GoTop 在 win 下没解决,完全迁移到 linux 下了,win 下部分机制用不了。
    GoTop
        3
    GoTop  
       2018-12-26 08:19:05 +08:00
    @akmonde 如果不设置 time limit 的话,每个 task 的默认限制时长是多少秒呢
    akmonde
        4
    akmonde  
    OP
       2018-12-26 09:00:38 +08:00
    @GoTop 似乎会一直等待你跑完为止,不会限制。
    akmonde
        5
    akmonde  
    OP
       2018-12-26 09:02:37 +08:00
    @GoTop 给个笨一点的建议,如果你非要在 win 下,可以自己写时长计数,然后自己 kill 掉,不要用 celery 自带的 time limit,那玩意儿也有 bug。
    GoTop
        6
    GoTop  
       2018-12-27 08:42:58 +08:00
    @akmonde 恩,多谢,我去试试
    celery 这东西真烦啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4204 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:11 · PVG 18:11 · LAX 03:11 · JFK 06:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.