diff options
author | Viktor Shlapakov <vshlapakov@gmail.com> | 2015-04-21 17:47:55 +0300 |
---|---|---|
committer | Viktor Shlapakov <vshlapakov@gmail.com> | 2015-06-03 11:22:48 +0300 |
commit | b31114520a15477da7ad660765a0240b6f348944 (patch) | |
tree | 29ba4678efeb31aafe4b99bfe6c158cf53a4526c /test/test_producer.py | |
parent | 0e0f794802076db34e8e4dc597c38237e88f4b34 (diff) | |
download | kafka-python-b31114520a15477da7ad660765a0240b6f348944.tar.gz |
Clean and simplify retry logic
Diffstat (limited to 'test/test_producer.py')
-rw-r--r-- | test/test_producer.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/test_producer.py b/test/test_producer.py index c9bdc47..c0dc873 100644 --- a/test/test_producer.py +++ b/test/test_producer.py @@ -61,6 +61,9 @@ class TestKafkaProducerSendUpstream(unittest.TestCase): def _run_process(self, retries_limit=3, sleep_timeout=1): # run _send_upstream process with the queue stop_event = threading.Event() + retry_options = RetryOptions(limit=retries_limit, + backoff_ms=50, + retry_on_timeouts=False) self.thread = threading.Thread( target=_send_upstream, args=(self.queue, self.client, CODEC_NONE, @@ -68,8 +71,7 @@ class TestKafkaProducerSendUpstream(unittest.TestCase): 3, # batch length Producer.ACK_AFTER_LOCAL_WRITE, Producer.DEFAULT_ACK_TIMEOUT, - RetryOptions(limit=retries_limit, backoff_ms=50, - retry_on_timeouts=True), + retry_options, stop_event)) self.thread.daemon = True self.thread.start() @@ -121,7 +123,7 @@ class TestKafkaProducerSendUpstream(unittest.TestCase): # lets create a queue and add 10 messages for 10 different partitions # to show how retries should work ideally for i in range(10): - self.queue.put((TopicAndPartition("test", i), "msg %i", "key %i")) + self.queue.put((TopicAndPartition("test", i), "msg %i" % i, "key %i" % i)) def send_side_effect(reqs, *args, **kwargs): raise FailedPayloadsError(reqs) |