]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Prevent a double-timeout in TCPClient.
authorBen Darnell <ben@bendarnell.com>
Sun, 18 Jan 2015 16:31:26 +0000 (11:31 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 18 Jan 2015 16:31:26 +0000 (11:31 -0500)
This fixes a non-deterministic failure in the tests.
Also fix another less-common failure in test.util.refusing_port.

tornado/tcpclient.py
tornado/test/util.py

index 0abbea200584bf87ef3c9df0951614be8ebb5d19..163e5c16a4adc7cbe8d7f9718376924e309bd425 100644 (file)
@@ -111,6 +111,7 @@ class _Connector(object):
             if self.timeout is not None:
                 # If the first attempt failed, don't wait for the
                 # timeout to try an address from the secondary queue.
+                self.io_loop.remove_timeout(self.timeout)
                 self.on_timeout()
             return
         self.clear_timeout()
index 4f0c07e5e2216ecaa9e2fe672c49711e2984094a..358809f216e247014b2401089c9744a5cde336cc 100644 (file)
@@ -42,6 +42,7 @@ def refusing_port():
     # ephemeral port number to ensure that nothing can listen on that
     # port.
     server_socket, port = bind_unused_port()
+    server_socket.setblocking(1)
     client_socket = socket.socket()
     client_socket.connect(("127.0.0.1", port))
     conn, client_addr = server_socket.accept()