From adcd46c50f81ec68f3bb30c04a2b653d973b52cb Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Sat, 23 Sep 2023 21:10:36 +0200 Subject: [PATCH] also reset if there are no sessions --- qcodes/instrument/visa.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qcodes/instrument/visa.py b/qcodes/instrument/visa.py index d099c12294c..6af70f9efdb 100644 --- a/qcodes/instrument/visa.py +++ b/qcodes/instrument/visa.py @@ -266,8 +266,8 @@ def close(self) -> None: # The pyvisa-sim visalib has a session attribute but the resource manager is not generic in the # visalib type so we need to use ignore[attr-defined] to avoid errors on session not being defined. n_sessions = len(self.resource_manager.visalib.sessions) # type: ignore[attr-defined] - # if this instrument is the last one its safe to reset the device - if session_found and n_sessions == 1: + # if this instrument is the last one or there are no connected instruments its safe to reset the device + if (session_found and n_sessions == 1) or n_sessions == 0: # work around for https://github.com/pyvisa/pyvisa-sim/issues/83 # see other issues for more context # https://github.com/QCoDeS/Qcodes/issues/5356 and