Skip to content

Commit 953aa85

Browse files
committed
Fix thread.isAlive for py3.9 #19
Thread.isAlive is now Thread.is_alive, add a shim to smooth over the change.
1 parent e33989d commit 953aa85

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

library/cap1xxx.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,20 @@ def __init__(self):
205205
self.stop_event = threading.Event()
206206
self.daemon = True
207207

208+
def alive(self):
209+
try:
210+
return self.isAlive()
211+
except AttributeError:
212+
# Python >= 3.9
213+
return self.is_alive()
214+
208215
def start(self):
209-
if self.isAlive() == False:
216+
if self.alive() == False:
210217
self.stop_event.clear()
211218
threading.Thread.start(self)
212219

213220
def stop(self):
214-
if self.isAlive() == True:
221+
if self.alive() == True:
215222
# set event to signal thread to terminate
216223
self.stop_event.set()
217224
# block calling thread until thread really has terminated

0 commit comments

Comments
 (0)