I use CVBPy in Ubuntu 16.04 with CVB 13.01.3.
My software uses several thread. When interrupt my program with ctrl-c, this one freeze while deleting device factory object.
What is best way to close device and stream ?
My code :
self.device = cvb.DeviceFactory.open(driver, port=self.port)
self.stream = self.device.stream
del self.device #freeze on this line
I just tried to reproduce the freeze, however I was not able to reproduce it.
There might something in the code you left out?
In general I advise to use the
with statment for opening a device, as
del only decreases the refence count and the device may or may not close depending on the references left.
with cvb.DeviceFactory.open(...) as device:
stream = device.stream
# Note: stream.stop() blocks until the current image in progress is delivered -
# this may freeze your application if your device is waiting for a trigger
# that maybe never occurres!
# stream.abort() never blocks
# Here (no indet) the device is closed again and all HW resources are released.
# All objects depending on the device now only exist
# as empty shells. If you access them an exception is raised.
Thank you for your response.
I verify if all HW resources are released. And it’s ok.