Skip to content

Commit b07308e

Browse files
Only add signal handler on main thread (#668)
* Only add signal handler on main thread * Add comment to explain reasoning
1 parent a88e073 commit b07308e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dask_jobqueue/runner.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import signal
55
from contextlib import suppress
66
from enum import Enum
7+
import threading
78
from typing import Dict, Optional
89
import warnings
910
from tornado.ioloop import IOLoop
@@ -15,7 +16,10 @@
1516

1617

1718
# Close gracefully when receiving a SIGINT
18-
signal.signal(signal.SIGINT, lambda *_: sys.exit())
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())
1923

2024

2125
class Role(Enum):

0 commit comments

Comments
 (0)