Skip to content

Commit 4fcd255

Browse files
committed
Avoids infinite loop if no USB devices are attached
1 parent 5fbb8d9 commit 4fcd255

File tree

1 file changed

+2
-1
lines changed
  • Metro/Metro_RP2350_Minesweeper

1 file changed

+2
-1
lines changed

Metro/Metro_RP2350_Minesweeper/code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def update_ui():
123123
time.sleep(1)
124124

125125
good_devices = False
126-
while not good_devices:
126+
wait_time = time.monotonic() + 10 # wait up to 20 seconds for a good device to be found
127+
while not good_devices and time.monotonic() < wait_time:
127128
for device in usb.core.find(find_all=True):
128129
if device.manufacturer is not None:
129130
good_devices = True

0 commit comments

Comments
 (0)