Qcodes
Qcodes copied to clipboard
Use weakref.finalize to safely close instruments?
Currently we are relying on either __del__ to ensure that an instruments connections are closed when it is garbage collected.
This does not work well and is very hard to get right since ``del` may be called after the object has been destryed and close is no longer possible to call.
Therefor we are using atexit.finalize to close all instruments. This seems to work fairly well however it may make sence to use weakref.finalize to close each instrument.
Lifted from https://github.com/QCoDeS/Qcodes/issues/1882