Skip to content

Commit

Permalink
Fix thread.isAlive for py3.9
Browse files Browse the repository at this point in the history
Thread.isAlive is now Thread.is_alive, add shim to smooth over the change.
  • Loading branch information
Gadgetoid committed Nov 9, 2021
1 parent 612068e commit 3f19983
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions library/explorerhat/pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ def __init__(self):
self.stop_event = threading.Event()
self.daemon = True

def alive(self):
try:
return self.isAlive()
except AttributeError:
return self.is_alive()

def start(self):
if not self.isAlive():
if not self.alive():
self.stop_event.clear()
threading.Thread.start(self)

def stop(self):
if self.isAlive():
if self.alive():
self.stop_event.set()
self.join()

Expand Down
2 changes: 1 addition & 1 deletion library/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
url = 'http://shop.pimoroni.com',
classifiers = classifiers,
packages = ['explorerhat'],
install_requires= ['cap1xxx']
install_requires= ['cap1xxx>=0.1.4']
)

0 comments on commit 3f19983

Please sign in to comment.