Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Termination tasks with eventlet/gevent worker pool. #4019

Closed
alternativshik opened this issue May 7, 2017 · 28 comments
Closed

Termination tasks with eventlet/gevent worker pool. #4019

alternativshik opened this issue May 7, 2017 · 28 comments

Comments

@alternativshik
Copy link

This is a feature request about ability to terminate task execution when using eventlet or gevent TaskPool.

Now this feature presents only on Prefork TaskPool, but, I think, this is a useful feature for other Pools.

@auvipy
Copy link
Member

auvipy commented Jan 11, 2018

have you any suggested workarounds?

@jengelman
Copy link
Contributor

+1

@sreecodeslayer
Copy link

I believe the issue am facing while terminating the task has to do with this feature request

Am using the celery [ v4.1.0 ] with Flask as : celery -A run.celery worker -P eventlet -c 50 --loglevel=info

[2018-05-11 17:16:28,137: ERROR/MainProcess] pidbox command error: NotImplementedError("<class 'celery.concurrency.eventlet.TaskPool'> does not implement kill_job",)
Traceback (most recent call last):
  File "/home/sreenadh/Projects/test_project/.tp/lib/python3.5/site-packages/kombu/pidbox.py", line 101, in dispatch
    reply = handle(method, arguments)
  File "/home/sreenadh/Projects/test_project/.tp/lib/python3.5/site-packages/kombu/pidbox.py", line 122, in handle_cast
    return self.handle(method, arguments)
  File "/home/sreenadh/Projects/test_project/.tp/lib/python3.5/site-packages/kombu/pidbox.py", line 116, in handle
    return self.handlers[method](self.state, **arguments)
  File "/home/sreenadh/Projects/test_project/.tp/lib/python3.5/site-packages/celery/worker/control.py", line 164, in revoke
    request.terminate(state.consumer.pool, signal=signum)
  File "/home/sreenadh/Projects/test_project/.tp/lib/python3.5/site-packages/celery/worker/request.py", line 248, in terminate
    pool.terminate_job(self.worker_pid, signal)
  File "/home/sreenadh/Projects/test_project/.tp/lib/python3.5/site-packages/celery/concurrency/base.py", line 115, in terminate_job
    '{0} does not implement kill_job'.format(type(self)))
NotImplementedError: <class 'celery.concurrency.eventlet.TaskPool'> does not implement kill_job

I believe the killing would be possible using Eventlet API corresponding to the greenthread.kill() ?

@MrJeric0
Copy link

+1

4 similar comments
@seiyata
Copy link

seiyata commented Nov 28, 2018

+1

@basitiyidir
Copy link

+1

@antoarva
Copy link

+1

@RogerLiNing
Copy link

+1

@auvipy auvipy added this to the v5.0.0 milestone Mar 12, 2019
@tobiaskohler
Copy link

+1

@auvipy auvipy removed this from the v5.0.0 milestone Jun 29, 2019
@MarcDelahousse
Copy link

+1

@auvipy auvipy added this to the 5.1.0 milestone Jul 2, 2019
@ioliveros
Copy link

+1

@auvipy
Copy link
Member

auvipy commented Jul 16, 2019

send PR, +1 will be blocked

@xd404015353
Copy link

+1

@auvipy auvipy removed this from the 5.1.0 milestone Nov 6, 2019
@zhangzhw8
Copy link

+1

@auvipy auvipy added this to the 4.6 milestone Feb 26, 2020
@eugene-s
Copy link

+1

4 similar comments
@remi-debette
Copy link

+1

@AlphaCaprice
Copy link

AlphaCaprice commented Mar 13, 2020

+1

@ashishpahwa7
Copy link

+1

@Alea4jacta6est
Copy link

Alea4jacta6est commented Mar 17, 2020

+1

@AlphaCaprice
Copy link

Well, this https://celery.readthedocs.io/en/latest/reference/celery.contrib.abortable.html can be useful. You can try to abort your task from outside (set state to ABORTED) and check this state in task with some period, if state is ABORTED you can raise some Exception. What do you think about this?

@singh-atenekom
Copy link

singh-atenekom commented Dec 20, 2020

+1

@AlphaCaprice I tried this approach. I was not able to stop the process from outside. Everything is related to gevent third party app.

@auvipy auvipy removed this from the 4.6 milestone Jan 3, 2021
@auvipy
Copy link
Member

auvipy commented Jan 3, 2021

considering that we are going to move to python3.6+ asyncio/trio can we close this issue as won't fix??

@adityamagarde
Copy link

adityamagarde commented Feb 18, 2021

I found a workaround. Might not work for everyone though.

I had a loop that had to run a heavy process. Couldn't revoke the task so the entire loop ran. So before starting the task, I made a file(let's say task_id.txt) and put a logic to check if the file existed on every iteration. I could delete the testfile if I wanted to revoke and the logic would raise an exception.

This is similar to AbortableTask as in the current iteration will still run, but was a work around as I couldn't use AbortableTask in my case.

@thedrow
Copy link
Member

thedrow commented Feb 28, 2021

considering that we are going to move to python3.6+ asyncio/trio can we close this issue as won't fix??

Sadly, yes. No one has fixed this so far so it probably won't get fixed.
If you feel differently, please come up with a PR and we will revisit that decision.

@oxtime
Copy link

oxtime commented Sep 29, 2022

+100

@Dominux
Copy link

Dominux commented Jan 20, 2023

+1

2 similar comments
@adv-zl
Copy link

adv-zl commented Feb 7, 2023

+1

@Kanishk-Kumar
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests