class kafka.net.manager.KafkaConnectionManager(net, **configs)[source]
auth_failure(node_id)[source]

Return the most recent auth-class failure for node_id, or None if there is no sticky failure on record.

call_soon(coro, *args)[source]

Accepts a coroutine / awaitable / function and schedules it on the event loop.

Thread-safe.

Returns: Future

connection_delay(node_id)[source]

Connection delay in seconds.

Uses exponential backoff/retry with jitter. See KIP-144.

least_loaded_node()[source]

Choose the node with fewest outstanding requests, with fallbacks.

This method will prefer a node with an existing connection (not throttled) with no in-flight-requests. If no such node is found, a node will be chosen randomly from all nodes that are not throttled or “blacked out” (i.e., are not subject to a reconnect backoff). If no node metadata has been obtained, will return a bootstrap node.

Returns:

node_id or None if no suitable node was found

maybe_raise_auth_failure(node_id)[source]

Raise the cached auth-class failure for node_id if any.

run(coro, *args)[source]

Schedules coro on the event loop, blocks until complete, returns value or raises.

If an IO thread is running (via start()), the caller thread blocks on a cross-thread Event while the coroutine runs on the IO thread. Safe to call concurrently from multiple caller threads.

If no IO thread is running, falls back to driving the loop on the caller thread (legacy behavior).

async wait_for(future, timeout_ms)[source]

Await future with a timeout in ms. Raises KafkaTimeoutError on timeout.

Must be awaited from a coroutine running on this loop. The underlying future is not cancelled on timeout - it continues to run; the timeout only unblocks the awaiter.