Skip to content

Commit 4bdcb99

Browse files
[3.12] gh-110033: Fix signal test_interprocess_signal() (GH-110035) (#110040)
gh-110033: Fix signal test_interprocess_signal() (GH-110035) Fix test_interprocess_signal() of test_signal. Make sure that the subprocess.Popen object is deleted before the test raising an exception in a signal handler. Otherwise, Popen.__del__() can get the exception which is logged as "Exception ignored in: ...." and the test fails. (cherry picked from commit 7e0fbf5) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 9cf6d89 commit 4bdcb99

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Lib/test/signalinterproctester.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import os
23
import signal
34
import subprocess
@@ -59,6 +60,13 @@ def test_interprocess_signal(self):
5960
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
6061
'SIGALRM': 0})
6162

63+
# gh-110033: Make sure that the subprocess.Popen is deleted before
64+
# the next test which raises an exception. Otherwise, the exception
65+
# may be raised when Popen.__del__() is executed and so be logged
66+
# as "Exception ignored in: <function Popen.__del__ at ...>".
67+
child = None
68+
gc.collect()
69+
6270
with self.assertRaises(SIGUSR1Exception):
6371
with self.subprocess_send_signal(pid, "SIGUSR1") as child:
6472
self.wait_signal(child, 'SIGUSR1')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fix ``test_interprocess_signal()`` of ``test_signal``. Make sure that the
2+
``subprocess.Popen`` object is deleted before the test raising an exception
3+
in a signal handler. Otherwise, ``Popen.__del__()`` can get the exception
4+
which is logged as ``Exception ignored in: ...`` and the test fails. Patch by
5+
Victor Stinner.

0 commit comments

Comments
 (0)