Skip to content

I can‘t stop a task by its task_id #5209

Closed

Description

@Gaoyongxian666

[2018-12-02 23:53:58,955: INFO/MainProcess] Received task: tasks.add[bb1fe102-c1f9-4361-9370-1129900c0d52]
[2018-12-02 23:54:02,479: INFO/MainProcess] Terminating bb1fe102-c1f9-4361-9370-1129900c0d52 (Signals.SIGTERM)
[2018-12-02 23:54:02,490: ERROR/MainProcess] pidbox command error: NotImplementedError("<class 'celery.concurrency.eventlet.TaskPool'> does not implement kill_job",)
Traceback (most recent call last):
File "d:\envs\aidcs\lib\site-packages\kombu\pidbox.py", line 101, in dispatch
reply = handle(method, arguments)
File "d:\envs\aidcs\lib\site-packages\kombu\pidbox.py", line 122, in handle_cast
return self.handle(method, arguments)
File "d:\envs\aidcs\lib\site-packages\kombu\pidbox.py", line 116, in handle
return self.handlers[method](self.state, **arguments)
File "d:\envs\aidcs\lib\site-packages\celery\worker\control.py", line 163, in revoke
request.terminate(state.consumer.pool, signal=signum)
File "d:\envs\aidcs\lib\site-packages\celery\worker\request.py", line 249, in terminate
pool.terminate_job(self.worker_pid, signal)
File "d:\envs\aidcs\lib\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
[2018-12-02 23:55:38,956: INFO/MainProcess] Task tasks.add[bb1fe102-c1f9-4361-9370-1129900c0d52] succeeded in 100.0s: 8

this is my main code:

from celery.app.control import Control
from tasks import add, app

myControl=Control(app)
myControl.revoke(task_id="b11729b0-6272-4527-af9d-dc24c0ad492d", terminate=True)

finally,if i want to look at the state of the task only by task_id (just like above), how .

Activity

  1. dejlek commented on Dec 3, 2018

    @dejlek
    Contributor

    Even though I use different concurrency (prefork, using Redis as broker), I've seen the same problem - sometimes worker can't kill some tasks...

  2. 26huitailang commented on Dec 5, 2018

    @26huitailang

    I used the signal='SIGKILL' param and got Task handler raised error: Terminated(9,).

    Does that mean the task termination succeed?

    celery_app.control.revoke(celery_task_id, terminate=True, signal='SIGKILL')

    celery log:

    [2018-12-05 16:07:32,872: DEBUG/MainProcess] pidbox received method revoke(signal='SIGKILL', task_id='970f8054-b4ee-4f70-9814-4899852342bd', terminate=True) [reply_to:None ticket:None]
    [2018-12-05 16:07:32,873: INFO/MainProcess] Terminating 970f8054-b4ee-4f70-9814-4899852342bd (Signals.SIGKILL)
    [2018-12-05 16:07:33,068: ERROR/MainProcess] Task handler raised error: Terminated(9,)
    
  3. alwaysused commented on Jan 8, 2019

    @alwaysused

    The trackback is showing that the taskpool component you used in celery is implement based on eventlet which has not implemented terminate_job function yet. But the default setting is prefork taskpool which and is the only one who has implemented that function.

  4. alwaysused commented on Jan 9, 2019

    @alwaysused

    And if you want to look at the state of the task only by task_id, you can use :
    status = AsyncResult( id).status.The query is blocking which sent a request to your backend line database to get the status.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions