Improve auto-commit task handling when group_id is None
This commit is contained in:
@@ -91,8 +91,10 @@ class ConsumerCoordinator(BaseCoordinator):
|
||||
log.warning('Broker version (%s) does not support offset'
|
||||
' commits; disabling auto-commit.',
|
||||
self.config['api_version'])
|
||||
self.config['enable_auto_commit'] = False
|
||||
elif self.config['group_id'] is None:
|
||||
log.warning('group_id is None: disabling auto-commit.')
|
||||
self.config['enable_auto_commit'] = False
|
||||
else:
|
||||
interval = self.config['auto_commit_interval_ms'] / 1000.0
|
||||
self._auto_commit_task = AutoCommitTask(weakref.proxy(self), interval)
|
||||
@@ -192,7 +194,7 @@ class ConsumerCoordinator(BaseCoordinator):
|
||||
assignor.on_assignment(assignment)
|
||||
|
||||
# restart the autocommit task if needed
|
||||
if self.config['enable_auto_commit']:
|
||||
if self._auto_commit_task:
|
||||
self._auto_commit_task.enable()
|
||||
|
||||
assigned = set(self._subscription.assigned_partitions())
|
||||
@@ -364,9 +366,9 @@ class ConsumerCoordinator(BaseCoordinator):
|
||||
time.sleep(self.config['retry_backoff_ms'] / 1000.0)
|
||||
|
||||
def _maybe_auto_commit_offsets_sync(self):
|
||||
if self.config['api_version'] < (0, 8, 1):
|
||||
if self._auto_commit_task is None:
|
||||
return
|
||||
if self.config['enable_auto_commit']:
|
||||
|
||||
# disable periodic commits prior to committing synchronously. note that they will
|
||||
# be re-enabled after a rebalance completes
|
||||
self._auto_commit_task.disable()
|
||||
|
||||
Reference in New Issue
Block a user