Title: sys.cleanup() in PythonInterpreter close() method closing thread pool _socket.NIO_GROUP in
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jeff.allen, psterdale, zyasoft
Priority: normal Keywords:

Created on 2017-05-17.08:11:36 by psterdale, last changed 2018-03-23.20:52:54 by jeff.allen.

File name Uploaded Description Edit Remove psterdale, 2017-05-17.11:57:08 Sample python script , java code and logs
msg11374 (view) Author: Parisa (psterdale) Date: 2017-05-17.08:11:35
sys.cleanup() in org.python.util.PythonInterpreter.close() method closing thread pool _socket.NIO_GROUP in

Is thread pool needs to be recreated create_connection() function in if it is shutdown?
or Can we use org.python.util.PythonInterpreter instance without closing ? repeatedly shared across multiple threads?

Please suggest...

Thank you.
msg11375 (view) Author: Parisa (psterdale) Date: 2017-05-17.11:57:08
I have added below lines of code to create_connection() function in 

    if NIO_GROUP.isShutdown():
        log.debug("Theard pool is shutdown. Recreating...")
        global NIO_GROUP
        NIO_GROUP = NioEventLoopGroup(_NUM_THREADS, DaemonThreadFactory("Jython-Netty-Client-%s"))

Please suggest if there is any better way to handle this...
PFA sample java code and script to reproduce the issue.
Also logs from before and after fix.
msg11382 (view) Author: Jim Baker (zyasoft) Date: 2017-05-19.02:58:45
Interesting. I didn't consider lifecycle issues of PySystemState/PythonIntepreter and how it interacts with such Netty threadpools. Something like this could be the right answer, possibly on a per PySystemState to avoid causing ClassLoaders for Jython to not GC. In general we would prefer to avoid have such global singletons, convenient as they may have been for perhaps the most common case.
msg11731 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-01.07:32:13
Are we content to let 2.7.2 go out with Netty lifecycle issues (which seem to be an issue generally #2517, #2584)? It's a bit shabby, but (to me) not quick to fix.
Date User Action Args
2018-03-23 20:52:54jeff.allensetpriority: normal
milestone: Jython 2.7.2 ->
2018-03-01 07:32:14jeff.allensetnosy: + jeff.allen
messages: + msg11731
2017-06-08 18:28:30zyasoftsetmilestone: Jython 2.7.1 -> Jython 2.7.2
2017-05-19 02:58:45zyasoftsetnosy: + zyasoft
messages: + msg11382
2017-05-17 11:57:09psterdalesetfiles: +
messages: + msg11375
2017-05-17 08:11:37psterdalecreate