Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wondering what the best way to restart Celery is without losing any tasks during the restart.

I'm currently running it as a daemon using the init.d/ script provided with celery - everything is working great.

Nonetheless, I will need to restart it (I think?) in order for it to see code updates. My concern is if someone uploads a photo and we want to do processing on it during that 5s or so window that celery is restarting the task will be lost forever and we'll start seeing weird issues.

Is there a suggested way to reload code for celery without losing any transactions in the meantime?



share|improve this question
If you mean the worker, see… - it'll be fine – Kristian Glass Mar 21 '12 at 0:58

You can safely restart celery worker without losing any tasks with the TERM signal. So the celery will end the current tasks and die.

If you want your tasks to be retried if something goes wrong you can also use the acks_late option (Task.acks_late / CELERY_ACKS_LATE).

Q: How can I safely shut down the worker? (from:

Answer: Use the TERM signal, and the worker will finish all currently executing jobs and shut down as soon as possible. No tasks should be lost.

You should never stop worker with the KILL signal (-9), unless you’ve tried TERM a few times and waited a few minutes to let it get a chance to shut down. As if you do tasks may be terminated mid-execution, and they will not be re-run unless you have the acks_late option set (Task.acks_late / CELERY_ACKS_LATE).

To stop the worker (from:

Q: Stopping the worker

Shutdown should be accomplished using the TERM signal.

To send a TERM signal, use the linux command KILL (from:

kill - terminate a process SYNOPSIS

kill [ -s signal | -p ] [ -a ] [ -- ] pid ... kill -l [ signal ] DESCRIPTION

The command kill sends the specified signal to the specified process or process group. If no signal is specified, the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For other processes, it may be necessary to use the KILL (9) signal, since this signal cannot be caught.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.