Skip to main content

LocalEventManager

Event manager for local environments.

It extends the EventManager to emit SystemInfo events at regular intervals. The LocalEventManager is intended to be used in local environments, where the system metrics are required managing the Snapshotter and AutoscaledPool.

Hierarchy

Index

Methods

__aenter__

  • Initializes the local event manager upon entering the async context.

    It starts emitting system info events at regular intervals.


    Returns LocalEventManager

__aexit__

  • async __aexit__(*, exc_type, exc_value, exc_traceback): None
  • Closes the local event manager upon exiting the async context.

    It stops emitting system info events and closes the event manager.


    Parameters

    • optionalkeyword-onlyexc_type: type[BaseException] | None
    • optionalkeyword-onlyexc_value: BaseException | None
    • optionalkeyword-onlyexc_traceback: TracebackType | None

    Returns None

__init__

  • __init__(*, system_info_interval, event_manager_options): None
  • A default constructor.

    In most cases, you should use the from_config constructor to create a new instance based on the provided configuration.


    Parameters

    • optionalkeyword-onlysystem_info_interval: timedelta = timedelta(seconds=1)

      Interval at which SystemInfo events are emitted.

    • keyword-onlypersist_state_interval: timedelta

      Interval between emitted PersistState events to maintain state persistence.

    • keyword-onlyclose_timeout: timedelta | None

      Optional timeout for canceling pending event listeners if they exceed this duration.

    Returns None

emit

  • emit(*, event, event_data): None
  • Parameters

    • optionalkeyword-onlyevent: Literal[Event.PERSIST_STATE]
    • optionalkeyword-onlyevent_data: EventPersistStateData

    Returns None

on

  • on(*, event, listener): None

from_config

  • Create a new instance based on the provided Configuration.


    Parameters

    • optionalkeyword-onlyconfig: Configuration | None = None

      The Configuration instance. Uses the global (default) one if not provided.

    Returns LocalEventManager

off

  • off(*, event, listener): None
  • Remove a specific listener or all listeners for an event.


    Parameters

    • optionalkeyword-onlyevent: Event

      The Actor event for which to remove listeners.

    • optionalkeyword-onlylistener: EventListener[Any] | None = None

      The listener which is supposed to be removed. If not passed, all listeners of this event are removed.

    Returns None

wait_for_all_listeners_to_complete

  • async wait_for_all_listeners_to_complete(*, timeout): None
  • Wait for all currently executing event listeners to complete.


    Parameters

    • optionalkeyword-onlytimeout: timedelta | None = None

      The maximum time to wait for the event listeners to finish. If they do not complete within the specified timeout, they will be canceled.

    Returns None

Properties

active

active: bool

Indicate whether the context is active.