summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-20 12:56:08 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-11-20 12:56:08 +0100
commit107d94d8ba7afb0ee0bb3381a5e3185ff0d57476 (patch)
treea6869b5bffe87c42e6588415936771f96254736e
parentcbde10288cbe873f33820729aee4951ffde00764 (diff)
downloadaioeventlet-107d94d8ba7afb0ee0bb3381a5e3185ff0d57476.tar.gz
Fix test_tcp_hello(): wait until the server is listening
-rw-r--r--tests/test_network.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/test_network.py b/tests/test_network.py
index 8cc497c..be0bebd 100644
--- a/tests/test_network.py
+++ b/tests/test_network.py
@@ -24,10 +24,11 @@ class TcpEchoClientProtocol(tests.asyncio.Protocol):
class TcpServer(threading.Thread):
- def __init__(self, host, port):
+ def __init__(self, host, port, event):
super(TcpServer, self).__init__()
self.host = host
self.port = port
+ self.event = event
self.sock = None
self.client = None
@@ -39,6 +40,7 @@ class TcpServer(threading.Thread):
sock.bind((self.host, self.port))
sock.listen(1)
+ self.event.set()
client, addr = sock.accept()
self.client = client
try:
@@ -61,9 +63,11 @@ class NetworkTests(tests.TestCase):
host = '127.0.0.1'
message = b'Hello World!'
- server = TcpServer(host, port)
+ event = threading.Event()
+ server = TcpServer(host, port, event)
server.start()
self.addCleanup(server.stop)
+ event.wait()
proto = TcpEchoClientProtocol(message, self.loop)
coro = self.loop.create_connection(lambda: proto, host, port)