SAService Architect Back to designer
SAService ArchitectDocumentation
Framework lifecycle start_service / stop_service

Python 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_init runs once before infrastructure and function creation.
  • _MakerGroup uses asyncio.gather, cancels its context, and raises the first error.
  • build_stream_graph precedes bind_transports; managed connector cores start before graph resources, then Worker admission and ordinary Sources open before the aiohttp listener.
  • stop_service bounds Context once, calls on_stop, then runtime stop with the remaining deadline.

Python startup sequence

Python shutdown sequence

  • 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 hook

Mutates generated makers once.

initialize_infrastructuregenerated

Creates servers, clients, and infrastructure.

initialize_functionsgenerated

Runs function makers concurrently.

on_start / on_stopasync hooks

Run around runtime activation and drain.

run_shutdown_operationsruntime

Uses only the remaining shared deadline.

Lifecycle outline

configure -> make once -> bind -> start -> admit -> drain -> stop