From 98386606262329b29cf74bc894b048ac37dbd6cb Mon Sep 17 00:00:00 2001 From: Akshay Arora Date: Wed, 26 Oct 2016 20:34:01 +0530 Subject: [PATCH] call detach on all threads before exiting --- jnius/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jnius/__init__.py b/jnius/__init__.py index 34c2599..11c2414 100644 --- a/jnius/__init__.py +++ b/jnius/__init__.py @@ -36,3 +36,14 @@ class PythonJavaClass_(PythonJavaClass): return self.hashCode() == other.hashCode() PythonJavaClass = PythonJavaClass_ + + +# from https://gist.github.com/tito/09c42fb4767721dc323d +import threading +orig_thread_run = threading.Thread.run +def thread_check_run(*args, **kwargs): + try: + return orig_thread_run(*args, **kwargs) + finally: + jnius.detach() +threading.Thread.run = thread_check_run