I have a Java main() that is starting one or more Py4J ClientServer and python instance to connect back to the ClientServer (all use different port sets). This is working, but when the main completes, both Java and the python instance are not exiting
I'm starting the ClientServer as follows:
clientServer = new ClientServer(javaPort, GatewayServer.defaultAddress(), pythonPort,
GatewayServer.defaultAddress(), GatewayServer.DEFAULT_CONNECT_TIMEOUT,
GatewayServer.DEFAULT_READ_TIMEOUT, ServerSocketFactory.getDefault(),
SocketFactory.getDefault(), jep);
and python is started by passing in the two ports and doing as follows:
python_classifier.gateway = ClientServer(
java_parameters=JavaParameters(port=javaPort, auto_convert=True, auto_close=True),
python_parameters=PythonParameters(port=pythonPort, daemonize=False,
daemonize_connections=True),
python_server_entry_point=python_classifier)
I've tried setting deamonize=True, but then the connections start failing. I've also added a Java shutdown hook to try and kill the python Processes I've started, but it is not always being called.
So, any ideas on how to get python to quietly exit when the Java side has exited?