Skip to content
Snippets Groups Projects

Ensure that starting the JVM in a threaded environment results in the thread being attached as daemon

1 unresolved thread
Files
5
import logging
import os
import threading
import jpype as jp
@@ -53,3 +54,9 @@ class JVMManager:
# Prevent further startup argument changes.
if not self.startup_arguments.frozen:
self.startup_arguments.frozen = True
# Attach the thread as daemon if not the main thread.
# See https://github.com/jpype-project/jpype/issues/1169.
if threading.current_thread() is not threading.main_thread():
jp.java.lang.Thread.detach()
jp.java.lang.Thread.attachAsDaemon()
Loading