BrokerConnection

class kafka.BrokerConnection(host, port, afi, **configs)[source]
blacked_out()[source]

Return true if we are disconnected from the given node and can’t re-establish a connection yet

can_send_more()[source]

Return True unless there are max_in_flight_requests_per_connection.

check_version(timeout=2, strict=False)[source]

Attempt to guess the broker version.

Note: This is a blocking call.

Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ...

close(error=None)[source]

Close socket and fail all in-flight-requests.

Parameters:error (Exception, optional) – pending in-flight-requests will be failed with this exception. Default: kafka.errors.ConnectionError.
connect()[source]

Attempt to connect and return ConnectionState

connected()[source]

Return True iff socket is connected.

connecting()[source]

Returns True if still connecting (this may encompass several different states, such as SSL handshake, authorization, etc).

disconnected()[source]

Return True iff socket is closed

recv()[source]

Non-blocking network receive.

Return response if available

send(request, expect_response=True)[source]

send request, return Future()

Can block on network if request is larger than send_buffer_bytes