Skip to content

Commit fe17112

Browse files
committed
Attach signal only if imported from main thread
1 parent 9496296 commit fe17112

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/psij/executors/local.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
logger = logging.getLogger(__name__)
2020

2121

22-
if threading.current_thread() != threading.main_thread():
23-
raise ImportError('The psij module must be imported from the main thread.')
24-
25-
2622
def _handle_sigchld(signum: int, frame: Optional[FrameType]) -> None:
2723
_ProcessReaper.get_instance()._handle_sigchld()
2824

2925

30-
signal.signal(signal.SIGCHLD, _handle_sigchld)
26+
if threading.current_thread() != threading.main_thread():
27+
logger.warning('The psij module is being imported from a non-main thread. This prevents the'
28+
'use of signals in the local executor, which will slow things down a bit.')
29+
else:
30+
signal.signal(signal.SIGCHLD, _handle_sigchld)
3131

3232

33-
_REAPER_SLEEP_TIME = 0.2
33+
_REAPER_SLEEP_TIME = 0.1
3434

3535

3636
class _ProcessEntry(ABC):

0 commit comments

Comments
 (0)