Skip to content

Commit

Permalink
Updated docs on shutdown behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Nov 28, 2023
1 parent bdbe58c commit 2b5a2d0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion docs/consumer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -289,7 +314,6 @@ will be allowed to finish before the restart occurs.
`issue 374 <https://github.com/coleifer/huey/issues/374>`_ and
`PEP 446 <https://www.python.org/dev/peps/pep-0446/>`_.


.. _process-supervisors:

supervisord and systemd
Expand Down

0 comments on commit 2b5a2d0

Please sign in to comment.