Avoids infinite loop if no USB devices are attached
This commit is contained in:
parent
5fbb8d9277
commit
4fcd255f87
1 changed files with 2 additions and 1 deletions
|
|
@ -123,7 +123,8 @@ mouse = None
|
|||
time.sleep(1)
|
||||
|
||||
good_devices = False
|
||||
while not good_devices:
|
||||
wait_time = time.monotonic() + 10 # wait up to 20 seconds for a good device to be found
|
||||
while not good_devices and time.monotonic() < wait_time:
|
||||
for device in usb.core.find(find_all=True):
|
||||
if device.manufacturer is not None:
|
||||
good_devices = True
|
||||
|
|
|
|||
Loading…
Reference in a new issue