Repository navigation
Terminate job implementation for gevent concurrency backend - #9083
Conversation
Nusnus
left a comment
There was a problem hiding this comment.
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
celery/concurrency/gevent.py:121:32: E128 continuation line under-indented for visual indent
celery/concurrency/gevent.py:122:32: E128 continuation line under-indented for visual indent
celery/concurrency/gevent.py:123:32: E128 continuation line under-indented for visual indent
Nusnus
left a comment
There was a problem hiding this comment.
2024-06-19T12:10:02.3834851Z =========================== short test summary info ============================
2024-06-19T12:10:02.3835935Z FAILED t/unit/concurrency/test_gevent.py::test_TaskPool::test_terminate_job - AssertionError: Expected 'kill' to have been called once. Called 0 times.
2024-06-19T12:10:02.3837204Z FAILED t/unit/concurrency/test_gevent.py::test_apply_timeout::test_apply_timeout - TypeError: 'NoneType' object is not callable
2024-06-19T12:10:02.3838160Z = 2 failed, 3311 passed, 10 skipped, 3 xfailed, 59 warnings, 28910 subtests passed in 142.61s (0:02:22) =
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9083 +/- ##
==========================================
+ Coverage 78.03% 78.04% +0.01%
==========================================
Files 150 150
Lines 18750 18781 +31
Branches 3207 3211 +4
==========================================
+ Hits 14631 14658 +27
- Misses 3819 3821 +2
- Partials 300 302 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Do I need to do anything else? The current modifications are working well in our project. |
This PR looks good, and it appears that many people are requesting this change, so I’m pro moving forward. Can you provide a worker log that shows the behavior of the changes? @ldsink Ideally, it would be a log from This can accelerate the merge + increase confidence in the changes, although they do seem correct and have tests. Thank you 🙏 |
|
Define a test task and use gevent as celery concurrency pool. @celery_app.task
def test_task():
print("Enter task...")
time.sleep(10) # sleep 10 seconds here
print("Task End.")Start celery worker as
Cancel task with task = test_task.delay()
time.sleep(0.1)
celery_app.control.revoke(task.id, terminate=True)BeforeWorker will throw an exception and has no effect, the task still executed until the end. After patchWorker only print enter task and successfully terminate the task. Worker console log |
auvipy
left a comment
There was a problem hiding this comment.
can we have an integration test as well, please?
|
While this has fixed Is this related? I think maybe something was missed in this PR. I'm calling |
Try use app.control.revoke as my example code ? |
|
I see the same This could solve the issue import types
class TaskPool(base.BasePool):
"""GEvent Pool."""
def on_apply(self, target, args=None, kwargs=None, callback=None,
accept_callback=None, timeout=None,
timeout_callback=None, apply_target=base.apply_target, **_):
timeout = self.timeout if timeout is None else timeout
greenlet = self._quick_put(apply_timeout if timeout else apply_target,
target, args, kwargs, callback, accept_callback,
timeout=timeout,
timeout_callback=timeout_callback)
greenlet.terminate = types.MethodType(_terminate, greenlet)
return greenlet
def _terminate(self, signal):
self.kill()What do you think? |
|
I made a PR for it #9440 |
Description
Modify gevent.py to support terminate job. Ref: #6917 .
Fix: #4019 #8687