Celery Python revoke

落爺英雄遲暮 提交于 2019-12-11 10:54:10

问题


software -> celery:3.1.20 (Cipater) kombu:3.0.35 py:2.7.6
            billiard:3.3.0.22 py-amqp:1.4.9
platform -> system:Linux arch:64bit, ELF imp:CPython
loader   -> celery.loaders.default.Loader
settings -> transport:amqp results:amqp

Currently I have the following function:

task(bind=True, default_retry_delay=300, max_retries=3)
def A(self,a,b,c,**kwargs)
    .
    B()
    .
    .
    .
    code

This is the function I call to cancel A.

task(bind=True, default_retry_delay=300, max_retries=3)
def cancelA(self,a,b,c,**kwargs)
    revoke(job.reference, terminate=True)

When I call cancelA(), but function A() is in progress and executing function B(), task doesn't get REVOKED. I debug celery and I see that even after calling revoke the Task status in A() is PROGRESS, not REVOKED. Is this expected behavior? I noticed that when B() is not executing, just code inside A, Task is revoked properly. As workaround I sleep for few seconds after calling REVOKE to guarantee B() finished already.

来源:https://stackoverflow.com/questions/37039941/celery-python-revoke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!