Mixin for async lifecycle management for mixin-composed classes.
Concepts
Resource mixin: a plain class (does not inherit LifecycleMixin) with one or
multiple @lifecycle-decorated async-generator method(s). Code before yield is init;
code after yield is shutdown.
Composed class: the concrete class that inherits its resource mixins and
LifecycleMixin. This is the only class that should inherit LifecycleMixin.
Ordering: resources init in dependency order and shut down in the exact
reverse order. Order is resolved once, in LifecycleMixin.__init_subclass__, from
after / before arguments of @lifecycle-decorated methods.
| Class | |
Mixin managing the lifecycle of classes with @resource decorated methods. |
| Function | lifecycle |
Mark an async generator method as a lifecycle resource. |
| Function | _build |
Validate required resources and build lifecycle ordering edges. |
| Function | _collect |
Collect all methods from given class decorated with @lifecycle. |
| Constant | _ATTR |
Undocumented |
| Constant | _ATTR |
Undocumented |
| Constant | _ATTR |
Undocumented |
| Constant | _ATTR |
Undocumented |
| Constant | _LOGGER |
Undocumented |
| Type Variable | _ |
Undocumented |
| Type Alias | _ |
Undocumented |
| Variable | _ |
Undocumented |
None = None, *, after: _FuncOrFuncs = (), before: _FuncOrFuncs = ()) -> Callable[ [ _LifecycleFunc], _LifecycleFunc]:Mark an async generator method as a lifecycle resource.
Code before yield runs during initialization; code after yield runs during shutdown, in reverse lifecycle order.
| Parameters | |
_func:_LifecycleFunc | None | Undocumented |
after:_FuncOrFuncs | Ordering constraint. If the referenced resources are present in the final composed class, they are started before and stopped after this resource. Silently ignored for resources that are absent. |
before:_FuncOrFuncs | Ordering constraint. If the referenced resources are present in the final composed class, this resource is started before and stopped after them. Silently ignored for resources that are absent. |
requires:_FuncOrFuncs | Presence constraint. All referenced resources must be
present in the final composed class. This does not impose an ordering
constraint. Checked by LifecycleMixin.__init_subclass__. |
| Returns | |
_LifecycleFunc | Callable[ | Undocumented |
Undocumented
| Value |
|