Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 18 GitHub source documents. All source documents are searchable here.
Last updated: October 7, 2025
This content is meant to be consumed by AI agents via MCP. Click here to get the MCP configuration.
Note: In rare cases it may contain LLM hallucinations.
For authoritative documentation, please consult the official GLEIF vLEI trainings and the ToIP Glossary.
Coroutines are computer program components that generalize subroutines for non-preemptive multitasking by allowing execution to be suspended and resumed at will, enabling cooperative task scheduling without requiring preemptive operating system intervention.
Coroutines are program components that can be suspended and resumed at will, providing fine-grained control over execution flow without requiring preemptive scheduling. Unlike traditional subroutines that run to completion, coroutines can pause execution mid-stream and later continue from exactly where they left off, maintaining their execution state across suspension boundaries.
Within the KERI ecosystem, coroutines form the foundational concurrency model for asynchronous event processing. The KERIpy implementation leverages Python's asyncio framework to implement hierarchical asynchronous coroutines through the HIO (Hierarchical Asynchronous Coroutines and I/O) library.
KERI's event-driven architecture requires handling multiple concurrent operations:
KERI implementations use Doers (HIO's coroutine abstraction) for structured concurrency. Two primary patterns exist:
Pattern 1: doing.doify wrapper - Used when sub-generators are needed for complex suspension logic
Pattern 2: .recur() override - Simplified pattern for straightforward asynchronous operations without generator mechanics
super().recur() when overriding to maintain proper DoDoer execution flowyield/yield from are functionally necessary versus syntactically presentCoroutines provide weightless concurrency with minimal memory overhead compared to thread-based approaches, enabling KERI agents to handle thousands of concurrent AID operations efficiently.
Coroutines enable these operations to proceed cooperatively, yielding control when waiting for external events (network responses, cryptographic operations) and resuming when data becomes available.
The HIO framework implements Rich Flow Based Programming Hierarchical Structured Concurrency with Asynchronous IO, building on early work from the ioflo project. This provides:
Coroutines are particularly well-suited for implementing:
The choice of coroutines aligns with KERI's minimal sufficient means design principle—providing powerful concurrency capabilities without the complexity of thread-based or process-based parallelism. This enables KERIA cloud agents and Signify clients to handle thousands of concurrent identifier operations efficiently.