mirror of
https://github.com/python/cpython.git
synced 2025-09-08 01:41:19 +00:00
Make test_terminate() succeed or fail quickly.
This does not fix #19227, but should stop the Gentoo buildbot from hanging.
This commit is contained in:
parent
64801680d3
commit
4f35079858
1 changed files with 14 additions and 2 deletions
|
@ -270,7 +270,7 @@ class _TestProcess(BaseTestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _test_terminate(cls):
|
def _test_terminate(cls):
|
||||||
time.sleep(1000)
|
time.sleep(100)
|
||||||
|
|
||||||
def test_terminate(self):
|
def test_terminate(self):
|
||||||
if self.TYPE == 'threads':
|
if self.TYPE == 'threads':
|
||||||
|
@ -296,7 +296,19 @@ class _TestProcess(BaseTestCase):
|
||||||
|
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
|
||||||
self.assertEqual(join(), None)
|
if hasattr(signal, 'alarm'):
|
||||||
|
def handler(*args):
|
||||||
|
raise RuntimeError('join took too long: pid=%s' % p.pid)
|
||||||
|
old_handler = signal.signal(signal.SIGALRM, handler)
|
||||||
|
try:
|
||||||
|
signal.alarm(10)
|
||||||
|
self.assertEqual(join(), None)
|
||||||
|
signal.alarm(0)
|
||||||
|
finally:
|
||||||
|
signal.signal(signal.SIGALRM, old_handler)
|
||||||
|
else:
|
||||||
|
self.assertEqual(join(), None)
|
||||||
|
|
||||||
self.assertTimingAlmostEqual(join.elapsed, 0.0)
|
self.assertTimingAlmostEqual(join.elapsed, 0.0)
|
||||||
|
|
||||||
self.assertEqual(p.is_alive(), False)
|
self.assertEqual(p.is_alive(), False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue