Skip to content

Commit f4b5714

Browse files
committed
bpo-32662: Try making test_asyncio.test_server more reliable
1 parent 4666ec5 commit f4b5714

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/test/test_asyncio/test_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import socket
3+
import time
34
import threading
45
import unittest
56

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

1819
def client(sock, addr):
20+
time.sleep(0.2)
21+
sock.settimeout(2)
1922
sock.connect(addr)
2023
sock.send(HELLO_MSG)
2124
sock.recv_all(1)
@@ -33,7 +36,7 @@ async def main(srv):
3336
await srv.serve_forever()
3437

3538
srv = self.loop.run_until_complete(asyncio.start_server(
36-
serve, '127.0.0.1', 0, loop=self.loop, start_serving=False))
39+
serve, '0.0.0.0', 0, loop=self.loop, start_serving=False))
3740

3841
self.assertFalse(srv.is_serving())
3942

@@ -65,6 +68,7 @@ def test_start_unix_server_1(self):
6568
started = threading.Event()
6669

6770
def client(sock, addr):
71+
sock.settimeout(2)
6872
started.wait(5)
6973
sock.connect(addr)
7074
sock.send(HELLO_MSG)

0 commit comments

Comments
 (0)