Connection Managers
CommandsManager
pydoll.connection.managers.commands_manager.CommandsManager
Manages command lifecycle and ID assignment for CDP commands.
Handles command future creation, ID generation, and response resolution for asynchronous command execution.
Initialize command manager with empty state.
create_command_future
Create future for command and assign unique ID.
| PARAMETER | DESCRIPTION |
|---|---|
command
|
Command to prepare for execution.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Future
|
Future that resolves when command completes. |
resolve_command
Resolve pending command with its result.
A late response can arrive after the caller already timed out (its future was cancelled by asyncio.wait_for) but before the command was removed. Popping and checking done() avoids InvalidStateError in that window.
remove_pending_command
Remove pending command without resolving (for timeouts/cancellations).
EventsManager
pydoll.connection.managers.events_manager.EventsManager
Manages event callbacks, processing, and network logs.
Handles event callback registration, triggering, and maintains state for network logs and dialog information.
Initialize events manager with empty state.
start
Start the event-processing worker if not already running.
Called when a connection is established. The worker drains queued events in arrival order so event handling never blocks the WebSocket read loop. Its lifetime is bound to the connection: stop() is invoked from the receive loop's finally block, so the worker can never outlive the socket.
enqueue_event
Queue an event for ordered, non-blocking processing.
Queuing is O(1) and never awaits, so a slow event callback can never delay delivery of command responses on the read loop.
stop
async
Cancel the worker, await its exit, and drop any queued events.
Awaiting the cancelled task is what prevents "Task was destroyed but it is pending" warnings: the task is never garbage-collected while pending.
register_callback
Register callback for specific event type.
| PARAMETER | DESCRIPTION |
|---|---|
event_name
|
Event name to listen for.
TYPE:
|
callback
|
Function called when event occurs.
TYPE:
|
temporary
|
If True, callback removed after first trigger.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Callback ID for later removal. |