summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncore.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-05-16 13:21:53 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-05-16 13:21:53 (GMT)
commit3cb09064a3842b4f80768b983f7867d62a779cef (patch)
tree516998642b789427e5017d34f00760393060af0f /Lib/test/test_asyncore.py
parent0d4f08cee3b244cc3a5b5a88c0d280757d6c2449 (diff)
downloadcpython-3cb09064a3842b4f80768b983f7867d62a779cef.zip
cpython-3cb09064a3842b4f80768b983f7867d62a779cef.tar.gz
cpython-3cb09064a3842b4f80768b983f7867d62a779cef.tar.bz2
Issue #17992: Add timeouts to asyncore and asynchat tests so that they won't accidentally hang.
Diffstat (limited to 'Lib/test/test_asyncore.py')
-rw-r--r--Lib/test/test_asyncore.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index 57eb4fa..c02a976 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -20,7 +20,7 @@ except ImportError:
threading = None
HOST = support.HOST
-
+TIMEOUT = 3
HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX')
class dummysocket:
@@ -397,7 +397,10 @@ class DispatcherWithSendTests(unittest.TestCase):
self.assertEqual(cap.getvalue(), data*2)
finally:
- t.join()
+ t.join(timeout=TIMEOUT)
+ if t.is_alive():
+ self.fail("join() timed out")
+
class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
@@ -789,7 +792,11 @@ class BaseTestAPI:
t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1,
count=500))
t.start()
- self.addCleanup(t.join)
+ def cleanup():
+ t.join(timeout=TIMEOUT)
+ if t.is_alive():
+ self.fail("join() timed out")
+ self.addCleanup(cleanup)
s = socket.socket(self.family, socket.SOCK_STREAM)
s.settimeout(.2)