Skip to content

Commit

Permalink
Merge pull request #574 from GrayMissing/master
Browse files Browse the repository at this point in the history
add a new signal when a consumer exits but task unfinished
  • Loading branch information
coleifer committed Dec 29, 2020
2 parents a4b8044 + 0b3408b commit b953913
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/signals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The following signals are implemented by Huey:
* ``SIGNAL_REVOKED``: task is revoked and will not be executed.
* ``SIGNAL_SCHEDULED``: task is not yet ready to run and has been added to the
schedule for future execution.
* ``SIGNAL_INTERRUPTED``: task is interrupted when consumer exits

When a signal handler is called, it will be called with the following
arguments:
Expand Down
1 change: 1 addition & 0 deletions huey/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def _execute(self, task, timestamp):
exception = exc
except KeyboardInterrupt:
logger.warning('Received exit signal, %s did not finish.', task.id)
self._emit(S.SIGNAL_INTERRUPTED, task)
return
except Exception as exc:
logger.exception('Unhandled exception in task %s.', task.id)
Expand Down
1 change: 1 addition & 0 deletions huey/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
SIGNAL_RETRYING = 'retrying'
SIGNAL_REVOKED = 'revoked'
SIGNAL_SCHEDULED = 'scheduled'
SIGNAL_INTERRUPTED = "interrupted"


class Signal(object):
Expand Down

0 comments on commit b953913

Please sign in to comment.