process_connection_manager
drunc.grpc_testing_tools.process_connection_manager
Abstract Process Connection Manager
This module provides abstraction over different process execution methods (multiprocessing, SSH, etc.).
Classes
ProcessConnectionManager(env_vars=None)
Bases: ABC
Abstract base class for managing process connections.
Defines the interface that all process connection implementations must follow, whether using local multiprocessing or remote SSH execution.
Initialise process connection manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_vars
|
Dict[str, str]
|
Environment variables to set for all processes |
None
|
Source code in drunc/grpc_testing_tools/process_connection_manager.py
Functions
cleanup()
abstractmethod
create_process(process_id, target_func, *args, **kwargs)
abstractmethod
Create a new process handle for execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
str
|
Unique identifier for the process |
required |
target_func
|
Any
|
Function to execute as the process |
required |
*args
|
Positional arguments for target function |
()
|
|
**kwargs
|
Keyword arguments for target function |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RunningGrpcServer |
RunningGrpcServer
|
Handle for managing the created process |
Source code in drunc/grpc_testing_tools/process_connection_manager.py
get_process_handle(process_id)
Retrieve a process handle by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process_id
|
str
|
ID of the process to retrieve |
required |
Returns:
| Type | Description |
|---|---|
Optional[RunningGrpcServer]
|
RunningGrpcServer if found, None otherwise |
Source code in drunc/grpc_testing_tools/process_connection_manager.py
is_process_alive(handle)
abstractmethod
Check if a process is currently running.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
RunningGrpcServer
|
RunningGrpcServer to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if process is alive, False otherwise |
Source code in drunc/grpc_testing_tools/process_connection_manager.py
list_process_ids()
Get list of all managed process IDs.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of process IDs |
start_process(handle)
abstractmethod
Start execution of a process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
RunningGrpcServer
|
RunningGrpcServer for the process to start |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If process cannot be started |
Source code in drunc/grpc_testing_tools/process_connection_manager.py
stop_process(handle, timeout=10.0)
abstractmethod
Stop a running process gracefully.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
RunningGrpcServer
|
RunningGrpcServer for the process to stop |
required |
timeout
|
float
|
Maximum time to wait for graceful shutdown |
10.0
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If process cannot be stopped |
Source code in drunc/grpc_testing_tools/process_connection_manager.py
wait_for_termination(handle, timeout=None)
abstractmethod
Wait for a process to terminate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
RunningGrpcServer
|
RunningGrpcServer to wait for |
required |
timeout
|
Optional[float]
|
Maximum time to wait (None for indefinite) |
None
|