Skip to content

Commit

Permalink
Fix flaky 'test_signals' in test_subprocess.py
Browse files Browse the repository at this point in the history
  • Loading branch information
njsmith committed Mar 9, 2020
1 parent af276c6 commit 28af4b1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions trio/tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

posix = os.name == "posix"
if posix:
from signal import SIGKILL, SIGTERM, SIGINT
from signal import SIGKILL, SIGTERM, SIGUSR1
else:
SIGKILL, SIGTERM, SIGINT = None, None, None
SIGKILL, SIGTERM, SIGUSR1 = None, None, None


# Since Windows has very few command-line utilities generally available,
Expand Down Expand Up @@ -362,8 +362,15 @@ async def test_one_signal(send_it, signum):

await test_one_signal(Process.kill, SIGKILL)
await test_one_signal(Process.terminate, SIGTERM)
# Test that we can send arbitrary signals.
#
# We used to use SIGINT here, but it turns out that the Python interpreter
# has race conditions that can cause it to explode in weird ways if it
# tries to handle SIGINT during startup. SIGUSR1's default disposition is
# to terminate the target process, and Python doesn't try to do anything
# clever to handle it.
if posix:
await test_one_signal(lambda proc: proc.send_signal(SIGINT), SIGINT)
await test_one_signal(lambda proc: proc.send_signal(SIGUSR1), SIGUSR1)


@pytest.mark.skipif(not posix, reason="POSIX specific")
Expand Down

0 comments on commit 28af4b1

Please sign in to comment.