summaryrefslogtreecommitdiff
path: root/asyncio/test_utils.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-05 15:30:16 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-11-05 15:30:16 +0100
commitac10ccd53e4bc6a20f72c5dd8afb3ea7c1a98179 (patch)
tree0e1d3aec75a0dd44911fa1ff4d0e76cef1f8e101 /asyncio/test_utils.py
parentf803275de42ee06357fbba334592c0153b1ea25d (diff)
downloadtrollius-ac10ccd53e4bc6a20f72c5dd8afb3ea7c1a98179.tar.gz
Python issue #22641: On Python 3.4 and newer, the default SSL context for
client connections is now created using ssl.create_default_context(), for stronger security. Patch written by Antoine Pitrou.
Diffstat (limited to 'asyncio/test_utils.py')
-rw-r--r--asyncio/test_utils.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/asyncio/test_utils.py b/asyncio/test_utils.py
index ac7680d..3e5eee5 100644
--- a/asyncio/test_utils.py
+++ b/asyncio/test_utils.py
@@ -91,6 +91,13 @@ class SilentWSGIRequestHandler(WSGIRequestHandler):
class SilentWSGIServer(WSGIServer):
+ request_timeout = 2
+
+ def get_request(self):
+ request, client_addr = super().get_request()
+ request.settimeout(self.request_timeout)
+ return request, client_addr
+
def handle_error(self, request, client_address):
pass
@@ -138,7 +145,8 @@ def _run_test_server(*, address, use_ssl=False, server_cls, server_ssl_cls):
httpd = server_class(address, SilentWSGIRequestHandler)
httpd.set_app(app)
httpd.address = httpd.server_address
- server_thread = threading.Thread(target=httpd.serve_forever)
+ server_thread = threading.Thread(
+ target=lambda: httpd.serve_forever(poll_interval=0.05))
server_thread.start()
try:
yield httpd
@@ -160,12 +168,15 @@ if hasattr(socket, 'AF_UNIX'):
class UnixWSGIServer(UnixHTTPServer, WSGIServer):
+ request_timeout = 2
+
def server_bind(self):
UnixHTTPServer.server_bind(self)
self.setup_environ()
def get_request(self):
request, client_addr = super().get_request()
+ request.settimeout(self.request_timeout)
# Code in the stdlib expects that get_request
# will return a socket and a tuple (host, port).
# However, this isn't true for UNIX sockets,