Skip to content

Use time.sleep() #91

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

Merged
merged 1 commit into from
Jul 26, 2022
Merged
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
6 changes: 4 additions & 2 deletions adafruit_bus_device/i2c_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
====================================================
"""

import time

try:
from typing import Optional, Type
from types import TracebackType
Expand Down Expand Up @@ -150,7 +152,7 @@ def write_then_readinto(

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

def __exit__(
Expand All @@ -169,7 +171,7 @@ def __probe_for_device(self) -> None:
or that the device does not support these means of probing
"""
while not self.i2c.try_lock():
pass
time.sleep(0)
try:
self.i2c.writeto(self.device_address, b"")
except OSError:
Expand Down
4 changes: 3 additions & 1 deletion adafruit_bus_device/spi_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
====================================================
"""

import time

try:
from typing import Optional, Type
from types import TracebackType
Expand Down Expand Up @@ -89,7 +91,7 @@ def __init__(

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