[Python-checkins] bpo-32662: Try making test_asyncio.test_server more reliable (#5338)
Yury Selivanov
webhook-mailer at python.org
Fri Jan 26 01:31:06 EST 2018
https://github.com/python/cpython/commit/4112c5b97d9c1c7b034653d0e017ffa894a45c74
commit: 4112c5b97d9c1c7b034653d0e017ffa894a45c74
branch: master
author: Yury Selivanov <yury at magic.io>
committer: GitHub <noreply at github.com>
date: 2018-01-26T01:30:57-05:00
summary:
bpo-32662: Try making test_asyncio.test_server more reliable (#5338)
files:
M Lib/test/test_asyncio/test_server.py
diff --git a/Lib/test/test_asyncio/test_server.py b/Lib/test/test_asyncio/test_server.py
index 44d135db105..034293cb3f5 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 @@ def test_start_server_1(self):
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 @@ def client(sock, addr):
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 @@ 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)
More information about the Python-checkins
mailing list