Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
"""
Create a new USB context.
"""
context_p = libusb1.libusb_context_p()
result = libusb1.libusb_init(byref(context_p))
if result:
raise libusb1.USBError(result)
self.__context_p = context_p
def _exit(self):
context_p = self.__context_p
if context_p:
for handle in self.__hotplug_callback_dict.keys():
self.hotplugDeregisterCallback(handle)
pop = self.__close_set.pop
while True:
try:
closable = pop()
except self.__KeyError:
break
closable.close()
self.__libusb_exit(context_p)
self.__context_p = libusb1.libusb_context_p()
self.__added_cb = self.__null_pointer
self.__removed_cb = self.__null_pointer
def __init__(self):
"""
Create a new USB context.
"""
# Used to prevent an exit to cause a segfault if a concurrent thread
# is still in libusb.
self.__context_refcount = 0
self.__context_cond = threading.Condition()
context_p = libusb1.libusb_context_p()
result = libusb1.libusb_init(byref(context_p))
if result:
raise libusb1.USBError(result)
self.__context_p = context_p
def __init__(self):
"""
Create a new USB context.
"""
# Used to prevent an exit to cause a segfault if a concurrent thread
# is still in libusb.
self.__context_refcount = 0
self.__context_cond = threading.Condition()
self.__context_p = libusb1.libusb_context_p()
self.__hotplug_callback_dict = {}
self.__close_set = WeakSet()