mirror of https://github.com/python/cpython
gh-110033: Fix signal test_interprocess_signal() (#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.
This commit is contained in:
parent
757cbd4f29
commit
7e0fbf5175
|
@ -1,3 +1,4 @@
|
||||||
|
import gc
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -59,6 +60,13 @@ class InterProcessSignalTests(unittest.TestCase):
|
||||||
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
|
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
|
||||||
'SIGALRM': 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.assertRaises(SIGUSR1Exception):
|
||||||
with self.subprocess_send_signal(pid, "SIGUSR1") as child:
|
with self.subprocess_send_signal(pid, "SIGUSR1") as child:
|
||||||
self.wait_signal(child, 'SIGUSR1')
|
self.wait_signal(child, 'SIGUSR1')
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
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. Patch by
|
||||||
|
Victor Stinner.
|
Loading…
Reference in New Issue