diff options
Diffstat (limited to 'kafka/producer/kafka.py')
-rw-r--r-- | kafka/producer/kafka.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index 7c55b27..e1200f4 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -216,6 +216,9 @@ class KafkaProducer(object): api_version (str): specify which kafka API version to use. If set to 'auto', will attempt to infer the broker version by probing various APIs. Default: auto + api_version_auto_timeout_ms (int): number of milliseconds to throw a + timeout exception from the constructor when checking the broker + api version. Only applies if api_version set to 'auto' Note: Configuration parameters are described in more detail at @@ -251,6 +254,7 @@ class KafkaProducer(object): 'ssl_keyfile': None, 'ssl_crlfile': None, 'api_version': 'auto', + 'api_version_auto_timeout_ms': 2000 } def __init__(self, **configs): @@ -274,7 +278,7 @@ class KafkaProducer(object): # Check Broker Version if not set explicitly if self.config['api_version'] == 'auto': - self.config['api_version'] = client.check_version() + self.config['api_version'] = client.check_version(timeout=(self.config['api_version_auto_timeout_ms']/1000)) assert self.config['api_version'] in ('0.10', '0.9', '0.8.2', '0.8.1', '0.8.0') # Convert api_version config to tuple for easy comparisons |