task_service
Application-owned background task records and execution manager.
- class bedrock_server_manager.services.task_service.TaskRecord(*, epoch: str | None = None, revision: Annotated[int | None, Ge(ge=1), Le(le=9007199254740991)] = None, status: Literal['queued', 'running', 'completed', 'failed', 'cancelling', 'cancelled'], message: str, result: JsonValue = None, error: APIErrorResponse | None = None, username: str | None = None, access_server_id: str | None = None, access_token_id: str | None = None, access_owner_id: str | None = None, access_permissions: list[str] = [])
- model_config = {'allow_inf_nan': False, 'extra': 'forbid', 'frozen': True, 'hide_input_in_errors': True, 'revalidate_instances': 'always', 'strict': True, 'validate_default': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class bedrock_server_manager.services.task_service.TaskAccess(username: 'str | None', access_server_id: 'str | None', access_token_id: 'str | None', access_owner_id: 'str | None', access_permissions: 'frozenset[str]')
- class bedrock_server_manager.services.task_service.TaskManager(connection_manager: ConnectionManager | None, max_workers: int | None = None, *, diagnostics: Diagnostics | None = None)
Manage background tasks using asyncio.
- property active_task_count: int
Count unfinished managed operations, including plugin-owned tasks.
- property tasks: Dict[str, TaskRecord]
Independent snapshots; execution records remain owned by this manager.
- task_access(task_id: str) TaskAccess | None
Read only authorization metadata for one task; never copy result payloads.
- async run_task(target_function: Callable, username: str | None = None, *args: Any, _plugin_owner: str | None = None, **kwargs: Any) str
Submit owned sync or async work and return its task ID.
- async report_stage(message: str) None
Publish a core operation stage without retaining its request arguments.
- async report_plugin_stage(message: str, *, plugin_owner: str | None) None
Allow a plugin to describe only its own active managed task.
- report_progress(percent: float, *, plugin_owner: str | None = None) None
Update only the current running task; progress is unknown until reported.
- diagnostic_snapshot() TasksDiagnostics
Read bounded task identity and timing without arguments or result payloads.
- async cancel_task(task_id: str) bool
Attempts to cancel a running task.
- Parameters:
task_id – The ID of the task to cancel.
- Returns:
True if the task was found and cancellation was requested, False otherwise.
- begin_shutdown() None
Close admission before producers and running operations are drained.
- async shutdown()
Waits for all background tasks to complete asynchronously.