mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Update test/signalinterproctester.py to 3.14.6 (#8173)
* Update `test/signalinterproctester.py` to 3.14.6 * Add `signalinterproctester.py` as a test dependency of `test_signal.py`
This commit is contained in:
1 parent
8cb96ebcbb
commit
9c027d4f67
2 files changed
+21
-7
No files matched your search
Vendored
+15
-7
@@ -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):
|
||||
@@ -27,16 +29,15 @@ class InterProcessSignalTests(unittest.TestCase):
|
||||
# (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)
|
||||
@@ -59,6 +60,13 @@ class InterProcessSignalTests(unittest.TestCase):
|
||||
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')
|
||||
|
||||
@@ -724,6 +724,12 @@ DEPENDENCIES = {
|
||||
"curses_tests.py",
|
||||
],
|
||||
},
|
||||
"signal": {
|
||||
"test": [
|
||||
"signalinterproctester.py",
|
||||
"test_signal.py",
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user