-
-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathpydev_is_thread_alive.py
More file actions
35 lines (22 loc) · 1.04 KB
/
pydev_is_thread_alive.py
File metadata and controls
35 lines (22 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from _pydev_bundle._pydev_saved_modules import threading
# Hack for https://www.brainwy.com/tracker/PyDev/363 (i.e.: calling is_alive() can throw AssertionError under some
# circumstances).
# It is required to debug threads started by start_new_thread in Python 3.4
_temp = threading.Thread()
if hasattr(_temp, "_os_thread_handle") and hasattr(_temp, "_started"): # Python 3.14 has no `_handle`
def is_thread_alive(t):
return not t._os_thread_handle.is_done()
elif hasattr(_temp, "_handle") and hasattr(_temp, "_started"): # Python 3.13 and later has this
def is_thread_alive(t):
return not t._handle.is_done()
elif hasattr(_temp, "_is_stopped"): # Python 3.12 and earlier has this
def is_thread_alive(t):
return not t._is_stopped
elif hasattr(_temp, "_Thread__stopped"): # Python 2.x has this
def is_thread_alive(t):
return not t._Thread__stopped
else:
# Jython wraps a native java thread and thus only obeys the public API.
def is_thread_alive(t):
return t.is_alive()
del _temp