Skip to content

Commit

Permalink
handle that _init could be missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Sep 25, 2023
1 parent 533502d commit 9ccc96a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion qcodes/instrument/visa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import logging
import warnings
from collections.abc import Sequence
from importlib.resources import as_file, files
from typing import Any
Expand Down Expand Up @@ -272,7 +273,15 @@ def close(self) -> None:
# see other issues for more context
# https://github.com/QCoDeS/Qcodes/issues/5356 and
# https://github.com/pyvisa/pyvisa-sim/issues/82
self.resource_manager.visalib._init()
try:
self.resource_manager.visalib._init()
except AttributeError:
warnings.warn(
"The installed version of pyvisa-sim does not have an `_init` method "
"in its visa library implementation. Cannot reset simulated instrument state. "
"On reconnect the instrument may retain settings set in this session."
)

super().close()

def write_raw(self, cmd: str) -> None:
Expand Down

0 comments on commit 9ccc96a

Please sign in to comment.