Skip to content

Commit 2009a25

Browse files
committed
Attach signal handler when starting reaper to avoid starting reaper on
import. It also solves some problems with starting jobs from subprocesses. However, a better solution for making things work properly in both parent process and subprocesses when fork is involved is to associate singleton threads with process IDs.
1 parent c185606 commit 2009a25

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/psij/executors/local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def _handle_sigchld(signum: int, frame: Optional[FrameType]) -> None:
2222
_ProcessReaper.get_instance()._handle_sigchld()
2323

2424

25-
signal.signal(signal.SIGCHLD, _handle_sigchld)
2625
_REAPER_SLEEP_TIME = 0.2
2726

2827

@@ -121,6 +120,7 @@ def get_instance(cls: Type['_ProcessReaper']) -> '_ProcessReaper':
121120
if cls._instance is None:
122121
cls._instance = _ProcessReaper()
123122
cls._instance.start()
123+
signal.signal(signal.SIGCHLD, _handle_sigchld)
124124
return cls._instance
125125

126126
def __init__(self) -> None:

0 commit comments

Comments
 (0)