Skip to content

receive_task

Part of Reusable workflows in the Python API reference.

Related guidance: shipped-tooling.

Runnable examples: receive_task.py.

from picogrid_ecn_client.workflows import receive_task

Register an echo handler and clean it up after task_limit requests.

async def receive_task(
client: ECNClient,
*,
entity_id: UUID,
command: str,
task_limit: int = 0,
on_event: Callable[[TaskRequestContext], None] | None = None,
on_registered: Callable[[TaskRegistration], None] | None = None,
) -> ReceiveTaskResult
NameTypeDefaultDescription
clientECNClientConfigured SDK client used to register the handler.
entity_idUUIDCanonical identity that owns the task handler.
commandstrExact command name accepted by the handler.
task_limitint0Requests to handle before cleanup; zero waits until interrupted while retaining only the most recent configured watcher buffer.
on_eventCallable[[TaskRequestContext], None] | NoneNoneOptional callback invoked for every accepted request context.
on_registeredCallable[[TaskRegistration], None] | NoneNoneOptional callback invoked after registration succeeds.
TypeDescription
ReceiveTaskResultRegistration metadata plus all positive-limit requests, or the most recently retained contexts and results from an unbounded receiver.
ExceptionDescription
ValidationErrorIf task_limit is negative or a request arrives after the configured limit has been accepted.
ECNClientErrorIf registration, request handling, or cleanup fails.

Source · workflows/tasks.py

Version 0.2.0 · branch main