【发布时间】:2014-06-13 08:38:34
【问题描述】:
我定义了一些时间限制为 1200 的任务:
@celery.task(time_limit=1200)
def create_ne_list(text):
c = Client()
return c.create_ne_list(text)
我也在使用worker_process_init 信号进行一些初始化,每次新进程启动时:
@worker_process_init.connect
def init(sender=None, conf=None, **kwargs):
init_system(celery.conf)
init_pdf(celery.conf)
这个初始化函数需要几秒钟来执行。
除此之外,我正在使用以下配置:
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json']
BROKER_URL = 'amqp://'
CELERY_RESULT_BACKEND = 'amqp://'
CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True
并使用以下命令启动我的工作人员:
celery -A isc worker -l info --concurrency=3
正如预期的那样,启动 worker 会导致初始化函数被调用 3 次。现在,我可以发送任务并且它们正在执行并且一切似乎都运行顺利。
但是:一旦一个任务超过了它的时间限制,worker就会陷入一个无限循环的产生并因为超过时间限制而再次被杀死。
[2014-06-13 09:46:18,978: ERROR/MainProcess] Timed out waiting for UP message from <Worker(Worker-20381, started daemon)>
[2014-06-13 09:46:20,000: ERROR/MainProcess] Process 'Worker-20381' pid:18953 exited with 'signal 9 (SIGKILL)'
// new worker 20382 getting started, initialization getting triggerd and soon after that -->
[2014-06-13 09:46:18,978: ERROR/MainProcess] Timed out waiting for UP message from <Worker(Worker-20382, started daemon)>
[2014-06-13 09:46:20,000: ERROR/MainProcess] Process 'Worker-20382' pid:18954 exited with 'signal 9 (SIGKILL)'
// and so on....
有人知道为什么会这样吗?
【问题讨论】: