vpelletier / python-libusb1

Python ctype-based wrapper around libusb1
GNU Lesser General Public License v2.1
168 stars 65 forks source link

Fix destruction of hotplug callbacks as a part of context teardown #62

Closed whitequark closed 3 years ago

whitequark commented 3 years ago

Before this commit, the callback would delete itself from the list, causing an exception:

  File ".../glasgow/device/hardware.py", line 207, in close
    self.usb_context.close()
  File ".../python-libusb1/build/lib/usb1/__init__.py", line 2288, in close
    self._exit()
  File ".../python-libusb1/build/lib/usb1/__init__.py", line 2296, in _exit
    for handle in self.__hotplug_callback_dict.keys():
RuntimeError: dictionary changed size during iteration