Skip to content

Commit 6bf64fc

Browse files
Only set signal handler in runners
1 parent 8f4d160 commit 6bf64fc

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

dask_jobqueue/runner.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
from distributed.worker import Worker
1616

1717

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

2425

2526
class Role(Enum):
@@ -68,6 +69,7 @@ def __init__(
6869
asynchronous: bool = False,
6970
loop: asyncio.BaseEventLoop = None,
7071
):
72+
setup_signal_handler()
7173
self.status = Status.created
7274
self.scheduler = scheduler
7375
self.scheduler_address = None

0 commit comments

Comments
 (0)