Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions Lib/test/signalinterproctester.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import gc
import os
import signal
import subprocess
import sys
import time
import unittest
from test import support


class SIGUSR1Exception(Exception):
Expand All @@ -27,16 +29,15 @@ def wait_signal(self, child, signame):
# (if set)
child.wait()

timeout = 10.0
deadline = time.monotonic() + timeout

while time.monotonic() < deadline:
start_time = time.monotonic()
for _ in support.busy_retry(support.SHORT_TIMEOUT, error=False):
if self.got_signals[signame]:
return
signal.pause()

self.fail('signal %s not received after %s seconds'
% (signame, timeout))
else:
dt = time.monotonic() - start_time
self.fail('signal %s not received after %.1f seconds'
% (signame, dt))

def subprocess_send_signal(self, pid, signame):
code = 'import os, signal; os.kill(%s, signal.%s)' % (pid, signame)
Expand All @@ -59,6 +60,13 @@ def test_interprocess_signal(self):
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
'SIGALRM': 0})

# gh-110033: Make sure that the subprocess.Popen is deleted before
# the next test which raises an exception. Otherwise, the exception
# may be raised when Popen.__del__() is executed and so be logged
# as "Exception ignored in: <function Popen.__del__ at ...>".
child = None
gc.collect()

with self.assertRaises(SIGUSR1Exception):
with self.subprocess_send_signal(pid, "SIGUSR1") as child:
self.wait_signal(child, 'SIGUSR1')
Expand Down
6 changes: 6 additions & 0 deletions scripts/update_lib/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,12 @@ def clear_import_graph_caches() -> None:
"curses_tests.py",
],
},
"signal": {
"test": [
"signalinterproctester.py",
"test_signal.py",
]
},
}


Expand Down
Loading