Skip to content

Commit

Permalink
bpo-32662: Try making test_asyncio.test_server more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
1st1 committed Jan 26, 2018
1 parent 4666ec5 commit f4b5714
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lib/test/test_asyncio/test_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import socket
import time
import threading
import unittest

Expand All @@ -16,6 +17,8 @@ def test_start_server_1(self):
HELLO_MSG = b'1' * 1024 * 5 + b'\n'

def client(sock, addr):
time.sleep(0.2)
sock.settimeout(2)
sock.connect(addr)
sock.send(HELLO_MSG)
sock.recv_all(1)
Expand All @@ -33,7 +36,7 @@ async def main(srv):
await srv.serve_forever()

srv = self.loop.run_until_complete(asyncio.start_server(
serve, '127.0.0.1', 0, loop=self.loop, start_serving=False))
serve, '0.0.0.0', 0, loop=self.loop, start_serving=False))

self.assertFalse(srv.is_serving())

Expand Down Expand Up @@ -65,6 +68,7 @@ def test_start_unix_server_1(self):
started = threading.Event()

def client(sock, addr):
sock.settimeout(2)
started.wait(5)
sock.connect(addr)
sock.send(HELLO_MSG)
Expand Down

0 comments on commit f4b5714

Please sign in to comment.