mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Fix signal handler in test.
This commit is contained in:
parent
240f86d7dd
commit
cc5c728513
1 changed files with 5 additions and 1 deletions
|
@ -354,12 +354,16 @@ class _TestProcess(BaseTestCase):
|
|||
else:
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
def handler(*args):
|
||||
raise RuntimeError('join took too long: %s' % p)
|
||||
raise RuntimeError('waitpid() took too long')
|
||||
old_handler = signal.signal(signal.SIGALRM, handler)
|
||||
try:
|
||||
signal.alarm(10)
|
||||
pid_status = os.waitpid(pid, 0)
|
||||
self.assertEqual(pid_status[0], pid)
|
||||
except RuntimeError:
|
||||
print('os.waitpid() =',
|
||||
os.waitpid(pid, os.WNOHANG), file=sys.stderr)
|
||||
raise
|
||||
finally:
|
||||
signal.alarm(0)
|
||||
signal.signal(signal.SIGALRM, old_handler)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue