Framework lifecycle
start_service / stop_servicePython lifecycle
asyncio maker groups, explicit construction phases, source-last start, and deadline-aware shutdown.
When to use
Use this page when implementing maker hooks, owning resources, or diagnosing startup and shutdown.
Behavior
custom_makers_initruns once before infrastructure and function creation._MakerGroupusesasyncio.gather, cancels its context, and raises the first error.build_stream_graphprecedesbind_transports; runtime start activates Sources last.stop_servicebounds Context once, callson_stop, then runtime stop with the remaining deadline.
Python startup sequence
ConfigurationLoad graph configResolve typed service, stream, connector, and endpoint settings.
Factories_initialize_makersInstall defaults, then run
custom_makers_init, custom_functions_init, and on_start.ConstructionInvoke makers onceCreate infrastructure and long-lived functions in parallel.
GraphBuild and bindConstruct streams, callers, endpoint consumers, and transports.
StartOpen admission lastStart dependencies and Sinks before Sources and servers.
Python shutdown sequence
SignalStop requestedCreate one deadline from
shutdownTimeout.AdmissionListeners and SourcesReject new root work and drain accepted calls.
GraphNested workKeep pools, storage, Sinks, and clients alive.
ResourcesPools, storage, SinksRelease graph dependencies in safe order.
TelemetryFlush and releaseMetrics, traces, and logs stop last.
- Network admission drains before endpoint state is released.
- Ordinary Sources stop before managed connector admission.
- Nested asyncio tasks drain before pools, storage, and Sinks.
- Timed-out detached tasks are cancelled and observed.
Hooks and boundaries properties
Generated extension points and runtime-owned lifecycle boundaries.
PropertyTypeDescription
custom_makers_initasync hookMutates generated makers once.
initialize_infrastructuregeneratedCreates servers, clients, and infrastructure.
initialize_functionsgeneratedRuns function makers concurrently.
on_start / on_stopasync hooksRun around runtime activation and drain.
run_shutdown_operationsruntimeUses only the remaining shared deadline.
Lifecycle outline
configure -> make once -> bind -> start -> admit -> drain -> stop