Skip to content

Commit

Permalink
Only add signal handler on main thread (#668)
Browse files Browse the repository at this point in the history
* Only add signal handler on main thread

* Add comment to explain reasoning
  • Loading branch information
jacobtomlinson authored Sep 5, 2024
1 parent a88e073 commit b07308e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dask_jobqueue/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import signal
from contextlib import suppress
from enum import Enum
import threading
from typing import Dict, Optional
import warnings
from tornado.ioloop import IOLoop
Expand All @@ -15,7 +16,10 @@


# Close gracefully when receiving a SIGINT
signal.signal(signal.SIGINT, lambda *_: sys.exit())
# We use SIGINT to shut down because the scheduler and worker hang
# if we call sys.exit() see https://github.com/dask/distributed/issues/8644
if threading.current_thread() is threading.main_thread():
signal.signal(signal.SIGINT, lambda *_: sys.exit())


class Role(Enum):
Expand Down

0 comments on commit b07308e

Please sign in to comment.