Skip to content

Commit a0e0677

Browse files
committed
Return future from commit_offsets_async
The callers of commit_offsets_async seem to imply it should return a future (eg. future = commit_offsets_async(...)), but it does not. This causes a mismatch between KafkaConsumer.commit_async()'s documentation and its behaviour. This fixes that by returning futures that were already available, we just had to actually return them.
1 parent 9ac3cb1 commit a0e0677

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kafka/coordinator/consumer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,13 @@ def commit_offsets_async(self, offsets, callback=None):
441441
response will be either an Exception or a OffsetCommitResponse
442442
struct. This callback can be used to trigger custom actions when
443443
a commit request completes.
444+
445+
Returns:
446+
kafka.future.Future
444447
"""
445448
self._invoke_completed_offset_commit_callbacks()
446449
if not self.coordinator_unknown():
447-
self._do_commit_offsets_async(offsets, callback)
450+
future = self._do_commit_offsets_async(offsets, callback)
448451
else:
449452
# we don't know the current coordinator, so try to find it and then
450453
# send the commit or fail (we don't want recursive retries which can
@@ -464,6 +467,8 @@ def commit_offsets_async(self, offsets, callback=None):
464467
# through delayed task execution.
465468
self._client.poll(timeout_ms=0) # no wakeup if we add that feature
466469

470+
return future
471+
467472
def _do_commit_offsets_async(self, offsets, callback=None):
468473
assert self.config['api_version'] >= (0, 8, 1), 'Unsupported Broker API'
469474
assert all(map(lambda k: isinstance(k, TopicPartition), offsets))

0 commit comments

Comments
 (0)