Skip to content

Commit

Permalink
fix: only set signal handlers from the main thread. #1312
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Jan 26, 2022
1 parent ed85bfb commit 29345e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion coverage/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import platform
import signal
import sys
import threading
import time
import warnings

Expand Down Expand Up @@ -528,8 +529,10 @@ def _init_for_start(self):
# It's useful to write debug info after initing for start.
self._should_write_debug = True

# Register our clean-up handlers.
atexit.register(self._atexit)
if not env.WINDOWS:
is_main = (threading.current_thread() == threading.main_thread())
if is_main and not env.WINDOWS:
# The Python docs seem to imply that SIGTERM works uniformly even
# on Windows, but that's not my experience, and this agrees:
# https://stackoverflow.com/questions/35772001/x/35792192#35792192
Expand Down

0 comments on commit 29345e7

Please sign in to comment.