rhapsody.backends.execution.concurrent¶
Concurrent distributed execution backend for parallel and distributed computing.
This module provides a backend that executes tasks on local or single node HPC resources.
ConcurrentExecutionBackend
¶
Bases: BaseBackend
Simple async-only concurrent execution backend.
Source code in src/rhapsody/backends/execution/concurrent.py
__await__
¶
submit_tasks
async
¶
Submit tasks for execution.
Source code in src/rhapsody/backends/execution/concurrent.py
cancel_task
async
¶
Cancel a task by its UID.
Parameters:
-
uid(str) –The UID of the task to cancel.
Returns:
-
bool(bool) –True if the task was found and cancellation was attempted, False otherwise.
Source code in src/rhapsody/backends/execution/concurrent.py
cancel_all_tasks
async
¶
Cancel all running tasks.
Source code in src/rhapsody/backends/execution/concurrent.py
shutdown
async
¶
Shutdown the executor.
Source code in src/rhapsody/backends/execution/concurrent.py
state
async
¶
Get backend state.
Returns:
-
str(str) –Current backend state (INITIALIZED, RUNNING, SHUTDOWN)
__aenter__
async
¶
__aexit__
async
¶
create
async
classmethod
¶
create(executor: Executor) -> ConcurrentExecutionBackend
Alternative factory method for creating initialized backend.
Parameters:
-
executor(Executor) –A concurrent.Executor instance (ThreadPoolExecutor or ProcessPoolExecutor).
Returns:
-
ConcurrentExecutionBackend–Fully initialized ConcurrentExecutionBackend instance.
Source code in src/rhapsody/backends/execution/concurrent.py
register_callback
¶
Register a callback function for task state changes.
This chains the user's callback with the internal callback used by wait_tasks(). Both callbacks will be invoked on every state change.
Parameters:
-
func(Callable[[dict[str, Any], str], None]) –A callable that will be invoked when task states change. The function should accept task and state parameters.