Skip to content

Commit ce67324

Browse files
Reduce indirection
1 parent 6bf64fc commit ce67324

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

dask_jobqueue/runner.py

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

1717

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())
24-
25-
2618
class Role(Enum):
2719
"""
2820
This Enum contains the various roles processes can be.
@@ -69,7 +61,11 @@ def __init__(
6961
asynchronous: bool = False,
7062
loop: asyncio.BaseEventLoop = None,
7163
):
72-
setup_signal_handler()
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())
7369
self.status = Status.created
7470
self.scheduler = scheduler
7571
self.scheduler_address = None

0 commit comments

Comments
 (0)