pywinusb icon indicating copy to clipboard operation
pywinusb copied to clipboard

Freeze when closing handle from __del__ during python exit

Open Ariakenom opened this issue 5 years ago • 12 comments

I tried to add a __del__ method for cleanup but it freezes if python exits while the object is alive.

Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32 pywinusb 0.4.2

import pywinusb.hid

class C:
  def __init__(self,h):
    self.h = h
  def __del__(self):
    print("closing")
    self.h.close()
    print("closed")

h = pywinusb.hid.HidDeviceFilter().get_devices()[0]
h.open()
c = C(h)
# del c  # works if do this before python exits

Ariakenom avatar Jun 27 '19 12:06 Ariakenom