Skip to content

try_lock increase wait time from 0 to 1 ms #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions adafruit_bus_device/i2c_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def write_then_readinto(

def __enter__(self) -> "I2CDevice":
while not self.i2c.try_lock():
time.sleep(0)
time.sleep(0.001)
return self

def __exit__(
Expand All @@ -170,7 +170,7 @@ def __probe_for_device(self) -> None:
or that the device does not support these means of probing
"""
while not self.i2c.try_lock():
time.sleep(0)
time.sleep(0.001)
try:
self.i2c.writeto(self.device_address, b"")
except OSError:
Expand Down
2 changes: 1 addition & 1 deletion adafruit_bus_device/spi_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(

def __enter__(self) -> SPI:
while not self.spi.try_lock():
time.sleep(0)
time.sleep(0.001)
self.spi.configure(
baudrate=self.baudrate, polarity=self.polarity, phase=self.phase
)
Expand Down