Best way to close camera

Hi everybody,

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 =, port=self.port) =
    del self.device #freeze on this line

Hi @gsFra
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 as 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.
1 Like

Thank you for your response.
I verify if all HW resources are released. And it’s ok.