Skip to content

Commit

Permalink
producer/kafka: Disable logging during object destruction (dpkp#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
gioele authored and chandlernine committed Jun 9, 2021
1 parent 0552b04 commit bddf777
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 @@ -444,6 +444,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(timeout=0)

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

0 comments on commit bddf777

Please sign in to comment.