Skip to content

Commit 1f6f442

Browse files
committed
Reset consumer fields to original values rather than defaults in FetchContext
1 parent 0d627a4 commit 1f6f442

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

kafka/consumer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,18 @@ def __init__(self, consumer, block, timeout):
4040

4141
def __enter__(self):
4242
"""Set fetch values based on blocking status"""
43+
self.orig_fetch_max_wait_time = self.consumer.fetch_max_wait_time
44+
self.orig_fetch_min_bytes = self.consumer.fetch_min_bytes
4345
if self.block:
4446
self.consumer.fetch_max_wait_time = self.timeout
4547
self.consumer.fetch_min_bytes = 1
4648
else:
4749
self.consumer.fetch_min_bytes = 0
4850

4951
def __exit__(self, type, value, traceback):
50-
"""Reset values to default"""
51-
self.consumer.fetch_max_wait_time = FETCH_MAX_WAIT_TIME
52-
self.consumer.fetch_min_bytes = FETCH_MIN_BYTES
52+
"""Reset values"""
53+
self.consumer.fetch_max_wait_time = self.orig_fetch_max_wait_time
54+
self.consumer.fetch_min_bytes = self.orig_fetch_min_bytes
5355

5456

5557
class Consumer(object):

0 commit comments

Comments
 (0)