Skip to content

Commit 55b9727

Browse files
Only set signal handler in runners (#697)
1 parent 8f4d160 commit 55b9727

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

dask_jobqueue/runner.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
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())
23-
24-
2518
class Role(Enum):
2619
"""
2720
This Enum contains the various roles processes can be.
@@ -68,6 +61,11 @@ def __init__(
6861
asynchronous: bool = False,
6962
loop: asyncio.BaseEventLoop = None,
7063
):
64+
# Close gracefully when receiving a SIGINT
65+
# We use SIGINT to shut down because the scheduler and worker hang
66+
# if we call sys.exit() see https://github.com/dask/distributed/issues/8644
67+
if threading.current_thread() is threading.main_thread():
68+
signal.signal(signal.SIGINT, lambda *_: sys.exit())
7169
self.status = Status.created
7270
self.scheduler = scheduler
7371
self.scheduler_address = None

0 commit comments

Comments
 (0)