Monkeypatch max_in_flight_requests_per_connection when checking broker version (#834)
This commit is contained in:
@@ -738,11 +738,15 @@ class BrokerConnection(object):
|
|||||||
|
|
||||||
Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ...
|
Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ...
|
||||||
"""
|
"""
|
||||||
# Monkeypatch the connection request timeout
|
# Monkeypatch some connection configurations to avoid timeouts
|
||||||
# Generally this timeout should not get triggered
|
override_config = {
|
||||||
# but in case it does, we want it to be reasonably short
|
'request_timeout_ms': timeout * 1000,
|
||||||
stashed_request_timeout_ms = self.config['request_timeout_ms']
|
'max_in_flight_requests_per_connection': 5
|
||||||
self.config['request_timeout_ms'] = timeout * 1000
|
}
|
||||||
|
stashed = {}
|
||||||
|
for key in override_config:
|
||||||
|
stashed[key] = self.config[key]
|
||||||
|
self.config[key] = override_config[key]
|
||||||
|
|
||||||
# kafka kills the connection when it doesnt recognize an API request
|
# kafka kills the connection when it doesnt recognize an API request
|
||||||
# so we can send a test request and then follow immediately with a
|
# so we can send a test request and then follow immediately with a
|
||||||
@@ -837,7 +841,8 @@ class BrokerConnection(object):
|
|||||||
raise Errors.UnrecognizedBrokerVersion()
|
raise Errors.UnrecognizedBrokerVersion()
|
||||||
|
|
||||||
log.removeFilter(log_filter)
|
log.removeFilter(log_filter)
|
||||||
self.config['request_timeout_ms'] = stashed_request_timeout_ms
|
for key in stashed:
|
||||||
|
self.config[key] = stashed[key]
|
||||||
return version
|
return version
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
Reference in New Issue
Block a user