You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to implement terminate_job for eventlet concurrency backend? #3429
I'm running eventlet based code in the celery task, and to have it properly patched I must use -P eventlet option while starting workers. With this option Celery uses eventlet based TaskPool and patches the code. However, I also need to be able to terminate the task. How could it be possible to write missing terminate_job code?
I have tried with the following code:
class TaskPool(base.BasePool):
...
def on_terminate(self):
from eventlet import greenthread
if self._pool is not None:
greenthread.kill(self.getcurrent())
def terminate_job(self, pid, signal=None):
self.terminate()
def terminate(self):
self._state = self.TERMINATE
self.on_terminate()
But it actually does not stop the execution. Plase help with valid approach.
Other option for me is to run celery in prefork mode, which support terminate method, and apply eventlet patch in the task file, but in this case I have an issue with django
DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 140575345698560 and this is thread id 140575293188528.
So I need any method to run eventlet code in the Celery task with the ability to stop it.
Plase advice.
changed the title [-]How it could be possible to implement `terminate_job` for eventlet concurrency backend?[/-][+]How it could be possible to implement terminate_job for eventlet concurrency backend?[/+]on Sep 6, 2016
changed the title [-]How it could be possible to implement terminate_job for eventlet concurrency backend?[/-][+]How to implement terminate_job for eventlet concurrency backend?[/+]on Sep 6, 2016
Activity
[-]How it could be possible to implement `terminate_job` for eventlet concurrency backend?[/-][+]How it could be possible to implement terminate_job for eventlet concurrency backend?[/+][-]How it could be possible to implement terminate_job for eventlet concurrency backend?[/-][+]How to implement terminate_job for eventlet concurrency backend?[/+]hostgame commentedon Oct 3, 2017
Same issue. Is it planned to implement job terminating in pools except prefork?
puzanov commentedon Oct 4, 2017
Anyone?
auvipy commentedon Dec 20, 2017
may be this issue is a guide for fix #3520
auvipy commentedon Aug 12, 2018
closing for lack of response.