Skip to content

Commit 6473abe

Browse files
author
Bongjun Hur
committed
add 5seconds timeout during link check
1 parent 8179adc commit 6473abe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,13 @@ def __init__(
178178

179179
# First wait link status is on
180180
# to avoid the code during DHCP - assert self.link_status, "Ethernet cable disconnected!"
181+
start_time = time.monotonic()
181182
while True:
183+
if self.link_status or ((time.monotonic() - start_time) > 5) :
184+
break
182185
time.sleep(1)
183186
if self._debug:
184-
print("My Link is:", self.link_status)
185-
if self.link_status: break
187+
print("My Link is:", self.link_status)
186188

187189
# Set DHCP
188190
if is_dhcp:

0 commit comments

Comments
 (0)