mode.proxy
¶
Proxy to service.
Works like a service, but delegates to underlying service object.
- class mode.proxy.ServiceProxy(*, loop: Optional[AbstractEventLoop] = None)¶
A service proxy delegates ServiceT methods to a composite service.
Example
>>> class MyServiceProxy(ServiceProxy): ... ... @cached_property ... def _service(self) -> ServiceT: ... return ActualService()
Notes
This is used by Faust, and probably useful elsewhere! The Faust App is created at module-level, and it uses service proxy to ensure the event loop is not also created just by importing a module.
- abstract: ClassVar[bool] = False¶
Set to True if this service class is abstract-only, meaning it will only be used as a base class.
- async add_async_context(context: AsyncContextManager) Any ¶
- add_context(context: ContextManager) Any ¶
- async crash(reason: BaseException) None ¶
- property crash_reason: Optional[BaseException]¶
- property crashed: bool¶
- property label: str¶
- logger: logging.Logger = <Logger mode.proxy (WARNING)>¶
- async maybe_start() bool ¶
- async restart() None ¶
- service_reset() None ¶
- set_shutdown() None ¶
- property shortlabel: str¶
- property should_stop: bool¶
- async start() None ¶
- property started: bool¶
- property state: str¶
- async stop() None ¶
- async wait_until_stopped() None ¶