diff options
author | Richard Oudkerk <shibturn@gmail.com> | 2013-10-12 23:49:27 (GMT) |
---|---|---|
committer | Richard Oudkerk <shibturn@gmail.com> | 2013-10-12 23:49:27 (GMT) |
commit | 4f35079858695e4d74a82a304332f70a0aa98e92 (patch) | |
tree | 3b8912dc0442cb83202b1a2ccfb4508ab9234a66 /Lib | |
parent | 64801680d3b8fe148da331b68923f06f626f01f1 (diff) | |
download | cpython-4f35079858695e4d74a82a304332f70a0aa98e92.zip cpython-4f35079858695e4d74a82a304332f70a0aa98e92.tar.gz cpython-4f35079858695e4d74a82a304332f70a0aa98e92.tar.bz2 |
Make test_terminate() succeed or fail quickly.
This does not fix #19227, but should stop the Gentoo buildbot from hanging.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_multiprocessing.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 6d20782..2b3ddcf 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -270,7 +270,7 @@ class _TestProcess(BaseTestCase): @classmethod def _test_terminate(cls): - time.sleep(1000) + time.sleep(100) def test_terminate(self): if self.TYPE == 'threads': @@ -296,7 +296,19 @@ class _TestProcess(BaseTestCase): 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.assertEqual(p.is_alive(), False) |