summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2018-01-26 06:30:57 (GMT)
committerGitHub <noreply@github.com>2018-01-26 06:30:57 (GMT)
commit4112c5b97d9c1c7b034653d0e017ffa894a45c74 (patch)
treed5e92750613a2ccd119cd872e6b4c54a58c7204f /Lib/test/test_asyncio
parent863b1e4d0e95036bca4e97c1b8b2ca72c19790fb (diff)
downloadcpython-4112c5b97d9c1c7b034653d0e017ffa894a45c74.zip
cpython-4112c5b97d9c1c7b034653d0e017ffa894a45c74.tar.gz
cpython-4112c5b97d9c1c7b034653d0e017ffa894a45c74.tar.bz2
bpo-32662: Try making test_asyncio.test_server more reliable (#5338)
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_server.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_server.py b/Lib/test/test_asyncio/test_server.py
index 44d135d..034293c 100644
--- a/Lib/test/test_asyncio/test_server.py
+++ b/Lib/test/test_asyncio/test_server.py
@@ -1,8 +1,10 @@
import asyncio
import socket
+import time
import threading
import unittest
+from test import support
from test.test_asyncio import utils as test_utils
from test.test_asyncio import functional as func_tests
@@ -16,6 +18,14 @@ class BaseStartServer(func_tests.FunctionalTestCaseMixin):
HELLO_MSG = b'1' * 1024 * 5 + b'\n'
def client(sock, addr):
+ for i in range(10):
+ time.sleep(0.2)
+ if srv.is_serving():
+ break
+ else:
+ raise RuntimeError
+
+ sock.settimeout(2)
sock.connect(addr)
sock.send(HELLO_MSG)
sock.recv_all(1)
@@ -33,7 +43,7 @@ class BaseStartServer(func_tests.FunctionalTestCaseMixin):
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, support.HOSTv4, 0, loop=self.loop, start_serving=False))
self.assertFalse(srv.is_serving())
@@ -65,6 +75,7 @@ class SelectorStartServerTests(BaseStartServer, unittest.TestCase):
started = threading.Event()
def client(sock, addr):
+ sock.settimeout(2)
started.wait(5)
sock.connect(addr)
sock.send(HELLO_MSG)