From 39fd0eee635b082826995d3f7ee047c0c1be510a Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 31 Aug 2014 23:33:28 -0400 Subject: [PATCH] Fix an erroneous return of None in IOStream.connect. This causes AttributeErrors in TCPClient, although I can only reproduce this case reliably on freebsd. Closes #1168. --- tornado/iostream.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tornado/iostream.py b/tornado/iostream.py index 99c681d8..1cc39d9f 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -993,6 +993,11 @@ class IOStream(BaseIOStream): """ self._connecting = True + if callback is not None: + self._connect_callback = stack_context.wrap(callback) + future = None + else: + future = self._connect_future = TracebackFuture() try: self.socket.connect(address) except socket.error as e: @@ -1008,12 +1013,7 @@ class IOStream(BaseIOStream): gen_log.warning("Connect error on fd %s: %s", self.socket.fileno(), e) self.close(exc_info=True) - return - if callback is not None: - self._connect_callback = stack_context.wrap(callback) - future = None - else: - future = self._connect_future = TracebackFuture() + return future self._add_io_state(self.io_loop.WRITE) return future