Closed hetsch closed 6 years ago
Thanks for the report.
for handle in self.__hotplug_callback_dict.keys():
RuntimeError: dictionary changed size during iteration
Woops, looks like I did not tell setup.py to run 2to3 when running on python3.
Should be fixed in 3926ad473f0c7e660520a7daa4d2b1254dacbe74 .
Now, why did travis not catch this ?
@vpelletier Thank you for fixing this issue, work perfect now. I'm sorry but I'm not really experienced with travis but if I have some spare time, I will try my best and have a look at the travis part ...
Thanks a lot for reporting that fix works.
Sorry about the travis bit, this was not an actual question but rather me being puzzled out loud.
@vpelletier There seems to be another issue with python3 and the hotplug_advanced.py
example. 2to3
outputs the following diff:
--- hotplug_advanced.py (original)
+++ hotplug_advanced.py (refactored)
@@ -18,7 +18,7 @@
Advanced hotplug examples.
Presents ways of integrating hotplug into your userland USB driver.
"""
-from __future__ import print_function
+
import select
import sys
import usb1
@@ -58,12 +58,12 @@
for fd_list, happened_flag in zip(
select.select(*([[
fd
- for fd, events in self._fd_dict.iteritems() if events & flag
+ for fd, events in self._fd_dict.items() if events & flag
] for flag in flag_list] + [timeout])),
flag_list,
):
result[fd] = result.get(fd, 0) | happened_flag
- return result.items()
+ return list(result.items())
# (end of demonstration helpers)
class AwesomeDevice(object):
@@ -227,7 +227,7 @@
)
try:
mode()
- except NoHotplugSupport, exc:
+ except NoHotplugSupport as exc:
print(exc.value)
sys.exit(1)
except (KeyboardInterrupt, SystemExit):
Applying these changes leads, at least on my platform, to the following error:
Traceback (most recent call last):
File "hotplug_advanced.py", line 237, in <module>
main()
File "hotplug_advanced.py", line 229, in main
mode()
File "hotplug_advanced.py", line 210, in eventloop
poller.poll()
File "/xxx/lib/python3.6/site-packages/usb1/__init__.py", line 1096, in poll
event_list = self.__poller.poll(usb_timeout)
File "hotplug_advanced.py", line 65, in poll
result[fd] = result.get(fd, 0) | happened_flag
NameError: name 'fd' is not defined
Hi,
first thank you for this library and your hard work! I tried to execute the
hotplug.py
from the examples directory. Works fine so far until I exit the program with^C
. This is the error that I get:I haven't attached any devices, just started and and then imediately exited the program without any other interaction.
My environment: