Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions kafka/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ def success(self, value):
# release (cheaper than `with`), callbacks snapshot under the lock,
# dispatch outside the lock, inlined callback loop (avoids an extra
# Python frame per completion).
# Clearing the lists releases any reference cycle held via stored
# bound methods (e.g. FutureProduceResult<->FutureRecordMetadata).
lock = self._lock
lock.acquire()
self.value = value
self.is_done = True
callbacks = self._callbacks
self._callbacks = None
self._errbacks = None
lock.release()
if callbacks:
error_on_callbacks = self.error_on_callbacks
Expand All @@ -61,6 +65,8 @@ def failure(self, e):
self.exception = exception
self.is_done = True
errbacks = self._errbacks
self._callbacks = None
self._errbacks = None
lock.release()
if errbacks:
error_on_callbacks = self.error_on_callbacks
Expand Down
Loading