diff options
author | gaosheng <jonathan.gonse@gmail.com> | 2017-02-20 23:48:55 +0800 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2017-03-06 15:25:31 -0800 |
commit | ebb6c3bd85638d4f09c0b392a7de65c63a8a20da (patch) | |
tree | 53531a42160522883b20e90a4c311c6825787cc0 | |
parent | fb09c0aa727141eaf0ec94c76a86b2f3b9328de8 (diff) | |
download | kafka-python-ebb6c3bd85638d4f09c0b392a7de65c63a8a20da.tar.gz |
change default timeout of KafkaProducer.close() to threading.TIMEOUT_MAX
-rw-r--r-- | kafka/producer/kafka.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index d5a94ad..f137b4e 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -400,8 +400,12 @@ class KafkaProducer(object): log.info('Kafka producer closed') return if timeout is None: - timeout = 999999999 - assert timeout >= 0 + # threading.TIMEOUT_MAX is available in Python3.3+ + timeout = getattr(threading, 'TIMEOUT_MAX', 999999999) + if getattr(threading, 'TIMEOUT_MAX', False): + assert 0 <= timeout <= getattr(threading, 'TIMEOUT_MAX') + else: + assert timeout >= 0 log.info("Closing the Kafka producer with %s secs timeout.", timeout) #first_exception = AtomicReference() # this will keep track of the first encountered exception |