diff options
author | Guido van Rossum <guido@python.org> | 2007-08-10 21:28:41 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-08-10 21:28:41 (GMT) |
commit | efdca3e071d4bf4d36c1b09f04547fbc3da83e62 (patch) | |
tree | 39a49cc26721c0f718430928daa6a2fc58ec03dc /Lib | |
parent | 6ae6ba09ea30bbb85d8a6d10bc495378ac40cfa4 (diff) | |
download | cpython-efdca3e071d4bf4d36c1b09f04547fbc3da83e62.zip cpython-efdca3e071d4bf4d36c1b09f04547fbc3da83e62.tar.gz cpython-efdca3e071d4bf4d36c1b09f04547fbc3da83e62.tar.bz2 |
Use an event variable to wait for the server to be ready, rather than sleep(0.1).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_telnetlib.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py index 0a3604e..c48de04 100644 --- a/Lib/test/test_telnetlib.py +++ b/Lib/test/test_telnetlib.py @@ -7,12 +7,13 @@ from unittest import TestCase from test import test_support -def server(evt): +def server(evt, ready): serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serv.settimeout(3) serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) serv.bind(("", 9091)) serv.listen(5) + ready.set() try: conn, addr = serv.accept() except socket.timeout: @@ -25,8 +26,9 @@ class GeneralTests(TestCase): def setUp(self): self.evt = threading.Event() - threading.Thread(target=server, args=(self.evt,)).start() - time.sleep(.1) + ready = threading.Event() + threading.Thread(target=server, args=(self.evt, ready)).start() + ready.wait() def tearDown(self): self.evt.wait() |