From a55179b5b33da21b15e29306ddff7e7dc4ba322d Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 7 Jul 2016 15:23:22 -0400 Subject: [PATCH 1/2] Protect against "socket is None" in iostream.close() with try/catch --- tchannel/tornado/connection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tchannel/tornado/connection.py b/tchannel/tornado/connection.py index 39635a02..4d23e4ce 100644 --- a/tchannel/tornado/connection.py +++ b/tchannel/tornado/connection.py @@ -310,7 +310,10 @@ def write(self, message): def close(self): if not self.closed: - self.connection.close() + try: + self.connection.close() + except: + log.exception('Error when closing connection') self.closed = True @tornado.gen.coroutine From dd258029cc172db33b51e07a78603ba2699d0f75 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 7 Jul 2016 15:35:54 -0400 Subject: [PATCH 2/2] Add comments --- tchannel/tornado/connection.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tchannel/tornado/connection.py b/tchannel/tornado/connection.py index 4d23e4ce..0f8f07ff 100644 --- a/tchannel/tornado/connection.py +++ b/tchannel/tornado/connection.py @@ -310,6 +310,9 @@ def write(self, message): def close(self): if not self.closed: + # TODO this is a temporary fix against "socket is None" error + # that randomly happens in vcr-related tests. + # https://github.com/uber/tchannel-python/issues/416 try: self.connection.close() except: