diff options
author | Guido van Rossum <guido@python.org> | 2007-09-06 03:57:23 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-09-06 03:57:23 (GMT) |
commit | 3da4c4bcaba549b27f3f3ba69ad7e58a585d5461 (patch) | |
tree | 00b8d6a67a29d5d776eb80f7b31c7a65da3842e7 /Lib/test/test_ftplib.py | |
parent | fdc1a567ecf3e747a63534279448cce39150964e (diff) | |
download | cpython-3da4c4bcaba549b27f3f3ba69ad7e58a585d5461.zip cpython-3da4c4bcaba549b27f3f3ba69ad7e58a585d5461.tar.gz cpython-3da4c4bcaba549b27f3f3ba69ad7e58a585d5461.tar.bz2 |
Use an event variable to wait for the server to be ready, not time.sleep().
Diffstat (limited to 'Lib/test/test_ftplib.py')
-rw-r--r-- | Lib/test/test_ftplib.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 9298bf4..62aae05 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -6,12 +6,13 @@ import time 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: @@ -28,8 +29,9 @@ class GeneralTests(TestCase): def setUp(self): ftplib.FTP.port = 9091 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() |