Events¶
EventDispatcher¶
EventDispatcher ¶
Dispatches CDP events to registered async handlers.
Each CDPSession and CDPClient owns an EventDispatcher. Handlers are isolated: if one raises, others still run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strict_events
|
bool
|
If True, handler exceptions are re-raised after logging, stopping dispatch to remaining handlers. Default False (fire-and-forget). |
False
|
on_event_error
|
EventErrorCallback | None
|
Optional callback invoked when a handler raises. Receives (event_name, params, exception). May be sync or async. |
None
|
Source code in cdpwave/events/dispatcher.py
on ¶
Register an async handler for a CDP event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
CDP event name (e.g. |
required |
handler
|
EventHandler
|
Async callable that receives the event params dict. |
required |
Returns:
| Type | Description |
|---|---|
Subscription
|
A Subscription that can be used to unsubscribe. |
Source code in cdpwave/events/dispatcher.py
off ¶
Remove a previously registered handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
CDP event name. |
required |
handler
|
EventHandler
|
The handler to remove. |
required |
Source code in cdpwave/events/dispatcher.py
dispatch
async
¶
Dispatch an event to all registered handlers.
Handler exceptions are caught and logged; other handlers still run. In strict mode, the first handler exception is re-raised after logging and the error callback runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
CDP event name. |
required |
params
|
dict[str, Any]
|
Event parameters dict from the CDP message. |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
If |
Source code in cdpwave/events/dispatcher.py
Subscription¶
Subscription ¶
Handle returned by on() for unsubscribing a handler.
Holds a weak reference to the dispatcher so that unsubscribing after the dispatcher is garbage-collected is a no-op.
Source code in cdpwave/events/handlers.py
unsubscribe ¶
EventHandler¶
EventHandler
module-attribute
¶
Async callable that receives CDP event params.