Skip to content

Commit 068231a

Browse files
authored
Merge pull request #91 from tekktrik/dev/use-sleep
Use time.sleep()
2 parents 3a15b83 + d5fab01 commit 068231a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

adafruit_bus_device/i2c_device.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
====================================================
88
"""
99

10+
import time
11+
1012
try:
1113
from typing import Optional, Type
1214
from types import TracebackType
@@ -150,7 +152,7 @@ def write_then_readinto(
150152

151153
def __enter__(self) -> "I2CDevice":
152154
while not self.i2c.try_lock():
153-
pass
155+
time.sleep(0)
154156
return self
155157

156158
def __exit__(
@@ -169,7 +171,7 @@ def __probe_for_device(self) -> None:
169171
or that the device does not support these means of probing
170172
"""
171173
while not self.i2c.try_lock():
172-
pass
174+
time.sleep(0)
173175
try:
174176
self.i2c.writeto(self.device_address, b"")
175177
except OSError:

adafruit_bus_device/spi_device.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
====================================================
1010
"""
1111

12+
import time
13+
1214
try:
1315
from typing import Optional, Type
1416
from types import TracebackType
@@ -89,7 +91,7 @@ def __init__(
8991

9092
def __enter__(self) -> SPI:
9193
while not self.spi.try_lock():
92-
pass
94+
time.sleep(0)
9395
self.spi.configure(
9496
baudrate=self.baudrate, polarity=self.polarity, phase=self.phase
9597
)

0 commit comments

Comments
 (0)