pyrolab/drivers/scopes/rohdeschwarz.py:110-121:
def connect(
self, address: str = "", hislip: bool = False, timeout: float = 1e3
) -> bool:
"""
timeout : int, optional
The device response timeout in milliseconds (default 1 ms).
Pass ``None`` for infinite timeout.
"""
rm = visa.ResourceManager()
if hislip:
self.device = rm.open_resource(f"TCPIP::{address}::hislip0")
else:
self.device = rm.open_resource(f"TCPIP::{address}")
- Docstring is wrong.
1e3 ms is 1 second, not 1 ms. A 1 ms VISA timeout would fail on essentially every operation, so a reader trying to raise the timeout from its apparent value will be confused about what units are in play.
timeout is typed float but documented int.
- The
ResourceManager is a local. pyvisa expects the ResourceManager to outlive the resources it opens; dropping the only reference leaves self.device depending on pyvisa's internal caching to stay valid. Store it as self._rm and close it in close().
The module docstring's "Common Issues" note already describes a failure mode where the scope is left "without data and with a bad connection" after a timeout -- worth checking whether the discarded ResourceManager contributes to that.
Found in a full-codebase audit at v0.4.0 (commit 1ce3146).
pyrolab/drivers/scopes/rohdeschwarz.py:110-121:1e3ms is 1 second, not 1 ms. A 1 ms VISA timeout would fail on essentially every operation, so a reader trying to raise the timeout from its apparent value will be confused about what units are in play.timeoutis typedfloatbut documentedint.ResourceManageris a local. pyvisa expects theResourceManagerto outlive the resources it opens; dropping the only reference leavesself.devicedepending on pyvisa's internal caching to stay valid. Store it asself._rmand close it inclose().The module docstring's "Common Issues" note already describes a failure mode where the scope is left "without data and with a bad connection" after a timeout -- worth checking whether the discarded
ResourceManagercontributes to that.Found in a full-codebase audit at v0.4.0 (commit 1ce3146).