Additional docstrings for autocommit close option

This commit is contained in:
Dana Powers 2017-03-13 16:39:53 -07:00
parent 195df5fb98
commit 92a66e3009
3 changed files with 17 additions and 3 deletions

View File

@ -377,7 +377,13 @@ class KafkaConsumer(six.Iterator):
return self._subscription.assigned_partitions()
def close(self, autocommit=True):
"""Close the consumer, waiting indefinitely for any needed cleanup."""
"""Close the consumer, waiting indefinitely for any needed cleanup.
Keyword Arguments:
autocommit (bool): If auto-commit is configured for this consumer,
this optional flag causes the consumer to attempt to commit any
pending consumed offsets prior to close. Default: True
"""
if self._closed:
return
log.debug("Closing the KafkaConsumer.")

View File

@ -538,8 +538,8 @@ class BaseCoordinator(object):
self.coordinator_id = None
def close(self):
"""Close the coordinator, leave the current group
and reset local generation/memberId."""
"""Close the coordinator, leave the current group,
and reset local generation / member_id"""
try:
self._client.unschedule(self.heartbeat_task)
except KeyError:

View File

@ -326,6 +326,14 @@ class ConsumerCoordinator(BaseCoordinator):
time.sleep(self.config['retry_backoff_ms'] / 1000.0)
def close(self, autocommit=True):
"""Close the coordinator, leave the current group,
and reset local generation / member_id.
Keyword Arguments:
autocommit (bool): If auto-commit is configured for this consumer,
this optional flag causes the consumer to attempt to commit any
pending consumed offsets prior to close. Default: True
"""
try:
if autocommit:
self._maybe_auto_commit_offsets_sync()