Skip to main content

EventManager

crawlee.events.event_manager.EventManager

Event manager for registering, emitting, and managing event listeners.

Event manager allows you to register event listeners, emit events, and wait for event listeners to complete their execution. It is built on top of the pyee.asyncio.AsyncIOEventEmitter class.

Index

Constructors

__init__

  • __init__(*, persist_state_interval, close_timeout): None
  • Create a new instance.


    Parameters

    • persist_state_interval: timedelta = timedelta(minutes=1)keyword-only
    • close_timeout: timedelta | None = Nonekeyword-only

    Returns None

Methods

__aenter__

  • async __aenter__(): EventManager
  • Initializes the event manager upon entering the async context.


    Returns EventManager

__aexit__

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

    This will stop listening for the events, and it will wait for all the event listeners to finish.


    Parameters

    • exc_type: type[BaseException] | None
    • exc_value: BaseException | None
    • exc_traceback: TracebackType | None

    Returns None

emit

  • emit(*, event, event_data): None
  • Emit an event.


    Parameters

    • event: Eventkeyword-only
    • event_data: EventDatakeyword-only

    Returns None

off

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


    Parameters

    • event: Eventkeyword-only
    • listener: Listener | None = Nonekeyword-only

    Returns None

on

  • on(*, event, listener): None
  • Add an event listener to the event manager.


    Parameters

    • event: Eventkeyword-only
    • listener: Listenerkeyword-only

    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

    • timeout: timedelta | None = Nonekeyword-only

    Returns None