a2a.server.agent_execution.active_task_registry module¶
- class a2a.server.agent_execution.active_task_registry.ActiveTaskRegistry(agent_executor: AgentExecutor, task_store: TaskStore, push_sender: PushNotificationSender | None = None)¶
Bases:
objectA registry for active ActiveTask instances.
- async aclose() None¶
Closes the registry and drains all active tasks.
Marks the registry closed so
get_or_createrefuses new work, then force-closes every registeredActiveTaskand awaits the in-flight_remove_taskcleanup tasks they schedule, so no SDK-ownedasyncio.Taskis left pending at event-loop shutdown. Safe to call multiple times.The close flag is set and the active-task snapshot is taken under
_lock, and the lock is then released before awaiting, because_remove_taskre-acquires_lock; holding it while draining would deadlock. Marking closed under the same lock prevents a concurrentget_or_createfrom registering a task that the drain would miss.
- async get(task_id: str) ActiveTask | None¶
Retrieves an existing task.
- async get_or_create(task_id: str, call_context: ServerCallContext, context_id: str | None = None, create_task_if_missing: bool = False, initial_message: Message | None = None) ActiveTask¶
Retrieves an existing ActiveTask or creates a new one.