Skip to content

Commit

Permalink
Detach only on android
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayaurora committed Oct 26, 2016
1 parent 9838660 commit b5a1ecb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions jnius/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ def equals(self, other):


# 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
if "ANDROID_ARGUMENT" in os.environ:
# on android, catch all exception to ensure about a jnius.detach
import threading
import jnius
orig_thread_run = threading.Thread.run

def jnius_thread_hook(*args, **kwargs):
try:
return orig_thread_run(*args, **kwargs)
finally:
jnius.detach()

threading.Thread.run = jnius_thread_hook

0 comments on commit b5a1ecb

Please sign in to comment.