Skip to content

Commit

Permalink
producer/kafka: Disable logging during object destruction (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
gioele authored Sep 7, 2020
1 parent 3a9d830 commit e4913db
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kafka/producer/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ def _unregister_cleanup(self):
self._cleanup = None

def __del__(self):
# Disable logger during destruction to avoid touching dangling references
class NullLogger(object):
def __getattr__(self, name):
return lambda *args: None

global log
log = NullLogger()

self.close()

def close(self, timeout=None):
Expand Down

0 comments on commit e4913db

Please sign in to comment.