From 77a645fb6170026058165b0bf4f23df130f41cf3 Mon Sep 17 00:00:00 2001 From: "Takacs, David" Date: Fri, 12 Sep 2014 12:40:43 +0200 Subject: [PATCH] Fixing second socet exception. The socket may get closed due to an error, in which case the close() in the finally clause raises a second exception. --- ner/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ner/utils.py b/ner/utils.py index 1d72d2c..3216b26 100644 --- a/ner/utils.py +++ b/ner/utils.py @@ -20,12 +20,11 @@ def tcpip4_socket(host, port): finally: try: s.shutdown(socket.SHUT_RDWR) + s.close() except socket.error: pass except OSError: pass - finally: - s.close() @contextmanager def http_connection(host, port):