Skip to content

Commit

Permalink
Run killall in a new greenlet.
Browse files Browse the repository at this point in the history
This prevents exiting immediately if a greenlet is tying up the CPU and
not switching.
  • Loading branch information
coleifer committed Jul 19, 2023
1 parent 6284422 commit 9cbf17e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions huey/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,10 @@ def _handle_stop_signal(self, sig_num, frame):
self._restart = False
self._graceful = False
if self.worker_type == WORKER_GREENLET:
gevent.killall([t for _, t in self.worker_threads],
KeyboardInterrupt)
def kill_workers():
gevent.killall([t for _, t in self.worker_threads],
KeyboardInterrupt)
gevent.spawn(kill_workers)

def _handle_restart_signal(self, sig_num, frame):
self._logger.info('Received SIGHUP, will restart')
Expand Down

0 comments on commit 9cbf17e

Please sign in to comment.