Skip to content

Commit 2e3f08b

Browse files
committed
Ensure that SIGHUP followed by SIGINT, the SIGINT is respected.
Refs #755
1 parent 054165e commit 2e3f08b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

huey/consumer.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def stop(self, graceful=False):
424424
self.scheduler.join()
425425
except KeyboardInterrupt:
426426
self._logger.info('Received request to shut down now.')
427+
self._restart = False
427428
else:
428429
self._logger.info('All workers have stopped.')
429430
else:
@@ -510,12 +511,14 @@ def check_worker_health(self):
510511

511512
def _set_signal_handlers(self):
512513
signal.signal(signal.SIGTERM, self._handle_stop_signal)
513-
if self.worker_type == WORKER_GREENLET:
514+
if self.worker_type in (WORKER_GREENLET, WORKER_THREAD):
514515
# Add a special INT handler when using gevent. If the running
515516
# greenlet is not the main hub, then Gevent will raise a
516517
# KeyboardInterrupt in the running greenlet by default. This
517518
# ensures that when INT is received we properly flag the main loop
518519
# for graceful shutdown and do NOT propagate the exception.
520+
# This is also added for threads to ensure that, in the event of a
521+
# SIGHUP followed by a SIGINT, we respect the SIGINT.
519522
signal.signal(signal.SIGINT, self._handle_interrupt_signal_gevent)
520523
else:
521524
signal.signal(signal.SIGINT, signal.default_int_handler)

0 commit comments

Comments
 (0)