From 0f5d35fa3489fa36000c05a891d375cc30672e23 Mon Sep 17 00:00:00 2001 From: Andre Araujo Date: Mon, 6 Nov 2017 16:00:34 -0800 Subject: 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. --- kafka/client_async.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'kafka/client_async.py') 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 = [] -- cgit v1.2.1