diff options
author | Andre Araujo <asdaraujo@gmail.com> | 2017-11-06 16:00:34 -0800 |
---|---|---|
committer | Jeff Widman <jeff@jeffwidman.com> | 2018-02-21 13:30:12 -0800 |
commit | 0f5d35fa3489fa36000c05a891d375cc30672e23 (patch) | |
tree | 0b8b15aa23544ff5f70e53423836711325700627 /kafka/client_async.py | |
parent | 54d64105c0fec604140b581fd0b0fb3f7ac54b50 (diff) | |
download | kafka-python-0f5d35fa3489fa36000c05a891d375cc30672e23.tar.gz |
Check timeout type in KafkaClient constructor
If a future was passed as the only positional parameter it would
be assigned to the "timeout_ms" parameter erroneously. This mistake
would not raise any exception but would lead to odd behaviour later,
what could make it extremely difficult to troubleshoot.
Adding a type check ensures that an exception is raise earlier to
notify the user about the problem.
Diffstat (limited to 'kafka/client_async.py')
-rw-r--r-- | kafka/client_async.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kafka/client_async.py b/kafka/client_async.py index 24a5bef..58155b8 100644 --- a/kafka/client_async.py +++ b/kafka/client_async.py @@ -545,6 +545,8 @@ class KafkaClient(object): timeout_ms = 100 elif timeout_ms is None: timeout_ms = self.config['request_timeout_ms'] + elif not isinstance(timeout_ms, (int, float)): + raise RuntimeError('Invalid type for timeout: %s' % type(timeout_ms)) # Loop for futures, break after first loop if None responses = [] |