Skip to content

Commit 92ec27a

Browse files
committed
try_lock increase wait time from 0 to 1 ms
1 parent 88250a1 commit 92ec27a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

adafruit_bus_device/i2c_device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def write_then_readinto(
151151

152152
def __enter__(self) -> "I2CDevice":
153153
while not self.i2c.try_lock():
154-
time.sleep(0)
154+
time.sleep(0.001)
155155
return self
156156

157157
def __exit__(
@@ -170,7 +170,7 @@ def __probe_for_device(self) -> None:
170170
or that the device does not support these means of probing
171171
"""
172172
while not self.i2c.try_lock():
173-
time.sleep(0)
173+
time.sleep(0.001)
174174
try:
175175
self.i2c.writeto(self.device_address, b"")
176176
except OSError:

adafruit_bus_device/spi_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __init__(
9393

9494
def __enter__(self) -> SPI:
9595
while not self.spi.try_lock():
96-
time.sleep(0)
96+
time.sleep(0.001)
9797
self.spi.configure(
9898
baudrate=self.baudrate, polarity=self.polarity, phase=self.phase
9999
)

0 commit comments

Comments
 (0)