objwatch.mp_handls module¶
- class objwatch.mp_handls.MPHandls(framework: str | None = None)[source]¶
Bases:
objectHandles multi-process initialization and synchronization using specified multi-process frameworks.
Supported frameworks: - ‘torch.distributed’: PyTorch’s distributed environment for multi-GPU support. - ‘multiprocessing’: Python’s built-in multiprocessing for parallel processing.
Manages process synchronization and provides the index of the current process.
- __init__(framework: str | None = None) None[source]¶
Initializes the handler with the specified framework.
- Parameters:
framework (
Optional[str]) – The multi-process framework to use.
- _check_initialized() None[source]¶
Verifies if the selected multi-process framework is initialized. Supports built-in frameworks and allows for custom framework extensions.
- get_index() int | None[source]¶
Returns the index of the current process.
- Returns:
The index of the current process (e.g., rank in distributed environments). Returns None if the framework is not initialized.
- Return type:
Optional[int]
- is_initialized() bool[source]¶
Checks if the multi-process framework has been initialized.
- Returns:
True if the framework is initialized, False otherwise.
- Return type: