dummynet.ProcessMonitor
¶
- class dummynet.ProcessMonitor(log)¶
The basic idea behind the monitor is to coordinate a process execution.
Typically scenario:
Run measurement software between two hosts
Start a server side waiting for clients to connect
Start a client and stop test once client exits
We should also ensure that the server applications started in 2 keeps running throughout the test and that it is closed when the client application exits.
- class Process(cmd: str, cwd, env, sudo, is_async, is_daemon, timeout, poller)¶
A process object to track the state of a process
- __init__(cmd: str, cwd, env, sudo, is_async, is_daemon, timeout, poller)¶
Construct a new process object.
- is_running()¶
Poll the process and update the return code
- stop()¶
Stop a process
- __init__(log)¶
Create a new test monitor
- keep_running(timeout=0.1)¶
Run the process monitor.
- Parameters:
timeout – A timeout in milliseconds. If this timeout expires we return.
- Returns:
True on timeout and processes are still running. If no processes are running anymore return False.
The following simple loop can be used to keep the monitor running while waiting for processes to exit:
- while test_monitor.keep_running():
pass
- stop()¶
Stop all processes