diff --git a/docs/consumer.rst b/docs/consumer.rst index 7bea5972..99eeeb99 100644 --- a/docs/consumer.rst +++ b/docs/consumer.rst @@ -271,6 +271,31 @@ they are currently executing before the process exits. Alternatively, you can shutdown the consumer using ``SIGTERM`` and any running tasks will be interrupted, ensuring the process exits quickly. +Huey does not guarantee at-least-once delivery of messages, and does not do +acknowledgement of completed tasks. This means that if you terminate the +consumer **without** letting it finish any currently-executing tasks, those +tasks will be lost. To be alerted when this occurs, you can use Huey's +:ref:`signals` (specifically ``signals.SIGNAL_INTERRUPTED``). The consumer will +emit this for tasks that are interrupted during execution. + +Deployments +^^^^^^^^^^^ + +When deploying new code, your best bet is to gracefully shutdown the Huey +consumer using ``SIGINT``, letting all running tasks finish, before starting a +new consumer process using the new code. + +If you have long-running tasks, an alternative option is to configure +your new code to use a separate storage. On Redis this is as simple as +specifying a new ``name`` for your ``RedisHuey()`` instance. Then you can start +the new code and new consumer, and they will operate independently of the +previously-running consumer. When all tasks are done, you can gracefully +shutdown the old consumer. + +.. note:: + It is always a good idea to implement a Huey `signals.SIGNAL_INTERRUPTED` + handler, even if all it does is log an exception about the interrupted task. + .. _consumer-restart: Consumer restart @@ -289,7 +314,6 @@ will be allowed to finish before the restart occurs. `issue 374 `_ and `PEP 446 `_. - .. _process-supervisors: supervisord and systemd