Skip to content

RTO.connect timeout docstring contradicts the default, and the ResourceManager is discarded #79

Description

@sequoiap

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}")
  1. 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.
  2. timeout is typed float but documented int.
  3. 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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions