-
-
Save manuelm/b981029383023baa973e to your computer and use it in GitHub Desktop.
_lib = None in _Initializer.__del__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/usb/backend/libusb1.py b/usb/backend/libusb1.py | |
index a90ae24..ae4ae4e 100644 | |
--- a/usb/backend/libusb1.py | |
+++ b/usb/backend/libusb1.py | |
@@ -437,10 +437,11 @@ class _ConfigDescriptor(object): | |
# initialize and finalize the library | |
class _Initializer(object): | |
- def __init__(self): | |
+ def __init__(self, lib): | |
_check(_lib.libusb_init(None)) | |
+ self.lib = lib | |
def __del__(self): | |
- _lib.libusb_exit(None) | |
+ self.lib.libusb_exit(None) | |
# iterator for libusb devices | |
@@ -666,7 +667,7 @@ def get_backend(): | |
if _lib is None: | |
_lib = _load_library() | |
_setup_prototypes(_lib) | |
- _init = _Initializer() | |
+ _init = _Initializer(_lib) | |
return _LibUSB() | |
except Exception: | |
_logger.error('Error loading libusb 1.0 backend', exc_info=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment