X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka.git/blobdiff_plain/18bc57adc610625742d7be9bc3422d02615d6d4f..a6b34f76661afd2f5d00ed72aa096bd01f1f8706:/src/busio.py diff --git a/src/busio.py b/src/busio.py index 1e636a0..279bd46 100755 --- a/src/busio.py +++ b/src/busio.py @@ -7,12 +7,15 @@ See `CircuitPython:busio` in CircuitPython for more details. * Author(s): cefn """ -import threading +try: + import threading +except ImportError: + threading = None -from adafruit_blinka import Enum, Lockable, agnostic -from adafruit_blinka.agnostic import board_id, detector import adafruit_platformdetect.constants.boards as ap_board import adafruit_platformdetect.constants.chips as ap_chip +from adafruit_blinka import Enum, Lockable, agnostic +from adafruit_blinka.agnostic import board_id, detector # pylint: disable=import-outside-toplevel,too-many-branches,too-many-statements # pylint: disable=too-many-arguments,too-many-function-args @@ -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):