run_iocsh.ioc¶
Class for running an IOC and capturing output.
Attributes¶
Classes¶
Class to wrap IOC process. |
Functions¶
|
Start IOC, wait for iocInit, sleep delay seconds, exit, check output. |
Module Contents¶
- class run_iocsh.ioc.IOC(*args: str, executable: str = DEFAULT_EXECUTABLE, timeout: float | None = DEFAULT_EXIT_TIMEOUT, fail_on: collections.abc.Sequence[str] = DEFAULT_FAIL_ON)[source]¶
Class to wrap IOC process.
Not thread-safe: all public methods should be called from a single thread. Internal reader threads are managed by the class itself.
- is_running() bool[source]¶
Return True if the subprocess is still running.
This only reflects subprocess state — it does NOT indicate that iocInit has completed, that records are available, or that CA/PVA is ready to serve clients. Use
wait_for_output()for IOC readiness checks.
- start() None[source]¶
Start the IOC subprocess.
- Raises:
IocshAlreadyRunningError: If the IOC is already running. IocshStateError: If the IOC has already exited.
- wait_for_output(pattern: str = 'iocRun: All initialization complete', timeout: float = DEFAULT_WAIT_FOR_TIMEOUT, poll_interval: float = DEFAULT_POLL_INTERVAL) None[source]¶
Block until
patternappears in stdout or stderr.Returns immediately if the pattern is already present in buffered output.
- Args:
pattern: Regex pattern to search for in combined stdout+stderr. timeout: Maximum seconds to wait before raising. poll_interval: Seconds to sleep between polls.
- Raises:
IocshStateError: If called before the process has started. IocshStartupError: If the IOC exits before the pattern appears. IocshTimeoutError: If
timeoutexpires while the IOC is still running.
- check_output(*, fail_on: collections.abc.Sequence[str] = DEFAULT_FAIL_ON) None[source]¶
Inspect accumulated output and raise on detected errors.
By default applies the
DEFAULT_FAIL_ONpatterns (^ERROR) plus the hardcoded checks (module not found, can’t open, missing shared library, file does not exist, non-zero exit code).- Args:
- fail_on: Regex patterns to match against combined stdout+stderr.
Replaces
DEFAULT_FAIL_ONentirely — pass(*DEFAULT_FAIL_ON, "MY:")to extend rather than replace. Pass()to disable pattern checks altogether.
- Raises:
IocshStateError: If called before the process has exited. IocshPatternMatchError: If any pattern matches the output. IocshModuleNotFoundError: If a module failed to load. IocshFileNotFoundError: If a file could not be opened or does not exist. IocshMissingSharedLibraryError: If a required shared library is missing. IocshProcessError: If the process exited with a non-zero code.
- run_iocsh.ioc.run_iocsh(*args: str, delay: float = DEFAULT_DELAY, timeout: float | None = DEFAULT_EXIT_TIMEOUT, executable: str = DEFAULT_EXECUTABLE, fail_on: collections.abc.Sequence[str] = DEFAULT_FAIL_ON) IOC[source]¶
Start IOC, wait for iocInit, sleep delay seconds, exit, check output.
- Returns:
The exited
IOCinstance. Access.stdoutand.stderrfor output inspection after the call returns.