From: Melissa LeBlanc-Williams Date: Tue, 14 Jul 2020 20:52:50 +0000 (-0700) Subject: Fix threading issue that stopped Blinka from working on MicroPython X-Git-Tag: 5.2.2^2 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/5189fd3e50e82697699bcd138e2116ced10eb5df Fix threading issue that stopped Blinka from working on MicroPython --- diff --git a/src/busio.py b/src/busio.py index 5456f65..279bd46 100755 --- a/src/busio.py +++ b/src/busio.py @@ -7,7 +7,10 @@ See `CircuitPython:busio` in CircuitPython for more details. * Author(s): cefn """ -import threading +try: + import threading +except ImportError: + threading = None import adafruit_platformdetect.constants.boards as ap_board import adafruit_platformdetect.constants.chips as ap_chip @@ -69,8 +72,8 @@ class I2C(Lockable): (scl, sda), i2cPorts ) ) - - self._lock = threading.RLock() + if threading is not None: + self._lock = threading.RLock() def deinit(self): """Deinitialization""" @@ -80,11 +83,13 @@ class I2C(Lockable): pass def __enter__(self): - self._lock.acquire() + if threading is not None: + self._lock.acquire() return self def __exit__(self, exc_type, exc_value, traceback): - self._lock.release() + if threading is not None: + self._lock.release() self.deinit() def scan(self):