python - How to reset time limit on Celery Task -
i have no experience celery i'm looking if use case solvable in celery.
the client submit job celery, job executed in celerytask. client has send keepalive every 30 seconds keep job active. once job not refreshed keepalive message, job cancelled.
i can think of 2 solutions:
each job-task created have hard time limit of 30s. when client sends keepalive router send message relevant worker reset hard time limit.
each job-task have no time limit. each job-task there special watchdog task launched. watchdog task launched delay of 30s. if new keepalive arrives client watchdog task cancelled , recreated. again delay of 30 seconds. if watchdog executed, kill job-task, eliminating system.
the 1. simpler, i'm not sure how reset task timelimit. solution 2. seems more correct, i'm afraid there various race conditions. watchdog task should running in separate queue reserved watchdogs only.
how possible? 1 of solution or other.
in understanding, want have middleware
(one receive keepalive
, on control task), link youcelery.app.control.control.terminate.
- get
task_id
of task whenapply_async
(destination
orall workers
) - listen
keepalive
client - if
time limit
arrived , nokeepalive
,terminate
taskapp.control.terminate(task_id, reply=true)
Comments
Post a Comment