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; managed connector cores start before graph resources, then Worker admission and ordinary Sources open before the aiohttp listener.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.
BindingBuild graph and endpointsBind streams, callers, endpoint consumers, functions, and transport routes.
Connector coreOpen clientsStart managed connector clients before anything can submit or poll.
DownstreamStart graph resourcesStart storage, pools, components, and Sinks before inbound work.
Worker admissionStart managed pollingOpen Temporal or other connector-owned inbound workers after Sinks are ready.
SourcesStart DataSourcesOpen ordinary graph admission only after every downstream dependency is ready.
ServersStart listenersOpen generated HTTP and gRPC listeners after endpoint bindings and graph resources are ready.
Python shutdown sequence
SignalStop requestedCreate one deadline from
shutdownTimeout.NetworkClose listenersReject new HTTP/gRPC requests and drain accepted handlers while graph dependencies remain alive.
SourcesDrain root workStop ordinary DataSources and admission-aware components.
WorkersStop managed admissionStop connector-owned polling only after ordinary Sources have drained.
ProducersPools, timers, storageStop admission and drain tasks that can still create graph work.
GraphParallelCall registryDrain only after no producer can create another child.
OutputStop DataSinksFlush results and accepted outbound submissions.
Connector coreClose clientsRelease managed connector clients after Sources, graph work, and Sinks no longer need them.
ReleaseRelease graph ownershipDrop endpoint consumers, streams, functions, and bindings only after their callbacks cannot run.
TelemetryFlush diagnosticsMetrics, traces, and logs cover shutdown and stop at the final safe boundary.
- Config reload, admission-aware Components, and aiohttp cleanup close first; accepted HTTP handlers retain endpoint state and graph dependencies while draining.
- Ordinary DataSources and regular Components stop next.
- Managed connector Worker admission stops only after ordinary Sources drain.
- DelayPool, TaskPools, PriorityTaskPools, deferred Components, and storage drain before the service task registry.
- After producers quiesce, registry snapshots drain repeatedly because one ParallelCall may create another.
- DataSinks stop before managed connector clients; metrics and tracing stop before logs.
- Timed-out asyncio shutdown operations 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