I am trying revoke a celery task with following commands.
revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed', terminate=True, signal='SIGKILL')
revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed', terminate=True)
revoke('d9078da5-9915-40a0-bfa1-392c7bde42ed')
None of which works, my worker pool is eventlet: Started with
$ celery -A scraper worker -P eventlet -c 1000 -l info
Please advise how to do this because i have a button in my django view which uses task I'd to cancel the task. There should be a way to do this but am not sure. With prefork pool it works.
[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
Error message says that Celery's TaskPool (Eventlet compatible version) does not have this feature. So you can either implement it yourself and send patch to Celery team or just leave a feature request and wait.
It should be very easy to copy prefork TaskPool code and adapt it to Eventlet API, greenthread.kill()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.