summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_poplib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-23 01:49:28 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-23 01:49:28 (GMT)
commitaccecdf96937ff0e34fb136ae1196814e100982c (patch)
treef468a9eddb86d98188208be3398d5e2c88f12695 /Lib/test/test_poplib.py
parentd745c436fb002177130b59386d37367719817452 (diff)
downloadcpython-accecdf96937ff0e34fb136ae1196814e100982c.zip
cpython-accecdf96937ff0e34fb136ae1196814e100982c.tar.gz
cpython-accecdf96937ff0e34fb136ae1196814e100982c.tar.bz2
Don't use a sleep to wait for the server to be ready; this caused
problems on my OSX laptop. use a condition variable instead.
Diffstat (limited to 'Lib/test/test_poplib.py')
-rw-r--r--Lib/test/test_poplib.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
index 35ff636..ef8565c 100644
--- a/Lib/test/test_poplib.py
+++ b/Lib/test/test_poplib.py
@@ -7,12 +7,13 @@ from unittest import TestCase
from test import test_support
-def server(evt):
+def server(ready, evt):
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:
@@ -28,8 +29,9 @@ class GeneralTests(TestCase):
def setUp(self):
self.evt = threading.Event()
- threading.Thread(target=server, args=(self.evt,)).start()
- time.sleep(.1)
+ self.ready = threading.Event()
+ threading.Thread(target=server, args=(self.ready, self.evt,)).start()
+ self.ready.wait()
def tearDown(self):
self.evt.wait()