从django视图中取消或撤销eventlet中的芹菜任务



我正在尝试用以下命令撤销芹菜任务。

revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed', terminate=True, signal='SIGKILL')
revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed', terminate=True)
revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed')

这些都不工作,我的工作池是eventlet:以

开始
$ celery -A scraper worker -P eventlet -c 1000 -l info

请告知如何做到这一点,因为我有一个按钮在我的django视图使用任务我取消任务。应该有办法做到这一点,但我不确定。使用预分叉池,它可以工作。

[2015-10-26 09:07:38,411: ERROR/MainProcess] pidbox command error: NotImplementedError("<class 'celery.concurrency.eventlet.TaskPool'> does not implement kill_job",)
Traceback (most recent call last):
  File "/Users/Michael/.virtualenvs/djangoscrape/lib/python2.7/site-packages/kombu/pidbox.py", line 105, in dispatch
    reply = handle(method, kwdict(arguments))
  File "/Users/Michael/.virtualenvs/djangoscrape/lib/python2.7/site-packages/kombu/pidbox.py", line 126, in handle_cast
    return self.handle(method, arguments)
  File "/Users/Michael/.virtualenvs/djangoscrape/lib/python2.7/site-packages/kombu/pidbox.py", line 120, in handle
    return self.handlers[method](self.state, **arguments)
  File "/Users/Michael/.virtualenvs/djangoscrape/lib/python2.7/site-packages/celery/worker/control.py", line 93, in revoke
    request.terminate(state.consumer.pool, signal=signum)
  File "/Users/Michael/.virtualenvs/djangoscrape/lib/python2.7/site-packages/celery/worker/job.py", line 307, in terminate
    pool.terminate_job(self.worker_pid, signal)
  File "/Users/Michael/.virtualenvs/djangoscrape/lib/python2.7/site-packages/celery/concurrency/base.py", line 116, in terminate_job
    '{0} does not implement kill_job'.format(type(self)))
NotImplementedError: <class 'celery.concurrency.eventlet.TaskPool'> does not implement kill_job

错误信息显示芹菜的TaskPool (Eventlet兼容版本)没有此功能。所以你可以自己实现它并将补丁发送给芹菜团队,或者只是留下一个功能请求并等待。

它应该是非常容易复制预分叉TaskPool代码,并使其适应Eventlet API, greenthread.kill() .

相关内容

  • 没有找到相关文章

最新更新