From 95bda3100178aca0e662d9afccd1d6771ba1df76 Mon Sep 17 00:00:00 2001 From: psterdale Date: Wed, 28 Jun 2017 18:46:13 +0530 Subject: [PATCH] sys.cleanup() in PythonInterpreter close() method closing thread pool _socket.NIO_GROUP in _socket.py Recreating NIO_GROUP pool if it is shutdown.. --- Lib/_socket.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/_socket.py b/Lib/_socket.py index 463093614..3741cacd6 100644 --- a/Lib/_socket.py +++ b/Lib/_socket.py @@ -1550,6 +1550,12 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, for the socket to bind as a source address before making the connection. An host of '' or port 0 tells the OS to use the default. """ + # Added check to recreate thread pool if it is already shutdown + if NIO_GROUP.isShutdown(): + log.debug("Theard pool is shutdown. Recreating...") + global NIO_GROUP + NIO_GROUP = NioEventLoopGroup(_NUM_THREADS, DaemonThreadFactory("Jython-Netty-Client-%s")) + sys.registerCloser(_shutdown_threadpool) host, port = address err = None