File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -306,6 +306,7 @@ def SpinOnce(self, timeout=0):
306
306
# connect for client
307
307
for client in self ._clients :
308
308
if not client ._connections :
309
+ clientSocket = None
309
310
try :
310
311
clientSocket = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
311
312
clientSocket .connect (client ._endpoint )
@@ -314,7 +315,9 @@ def SpinOnce(self, timeout=0):
314
315
clientSocket = client ._sslContext .wrap_socket (clientSocket , server_side = False )
315
316
clientSocket .setblocking (0 ) # TODO: deferred non-blocking after connect finishes, not ideal
316
317
except Exception as e :
317
- log .exception ('error while trying to create client connection: %s' , e )
318
+ if clientSocket :
319
+ clientSocket .close ()
320
+ log .exception ('error while trying to create client connection to %s: %s' , client ._endpoint , e )
318
321
continue
319
322
connection = client ._connectionClass (connectionSocket = clientSocket , remoteAddress = client ._endpoint )
320
323
client ._connections .append (connection )
You can’t perform that action at this time.
0 commit comments