producer/kafka: Disable logging during object destruction#2043
Merged
dpkp merged 1 commit intodpkp:masterfrom Sep 7, 2020
Merged
producer/kafka: Disable logging during object destruction#2043dpkp merged 1 commit intodpkp:masterfrom
dpkp merged 1 commit intodpkp:masterfrom
Conversation
Logging in an object destructor leads to crashes like the following ``` Exception ignored in: <bound method KafkaProducer.__del__ of <kafka.producer.kafka.KafkaProducer object at 0x7f0c47309b38>> Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/kafka/producer/kafka.py", line 447, in __del__ File "/usr/local/lib/python3.6/site-packages/kafka/producer/kafka.py", line 460, in close File "/usr/local/lib/python3.6/logging/__init__.py", line 1305, in info File "/usr/local/lib/python3.6/logging/__init__.py", line 1546, in isEnabledFor TypeError: '>=' not supported between instances of 'int' and 'NoneType' ``` In issue dpkp#1218 and dpkp#1445, @dpkp made it clear that producers should be closed while they are being destructed. This commit does not modify the existing architecture and code structure, and preserves all the logging calls in `close`. At the same time, by "nullifying" the logger, it fixes the crash that is inherent in the use of logging methods during the destruction of an object.
38f2d74 to
20f3cca
Compare
|
@dpkp, this has been open for awhile, is there any chance this makes it in? |
|
I see that the PR explicitly says that it is preserving all the log calls int he |
Owner
This is still a useful log message at INFO level, which generally should say when a producer connects, disconnects, etc. |
gabriel-tincu
pushed a commit
to aiven/kafka-python
that referenced
this pull request
Sep 22, 2020
chandlernine
pushed a commit
to layer9ai/kafka-python
that referenced
this pull request
Jun 9, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Logging in an object destructor leads to crashes like the following
In closing PR #1445, @dpkp made it clear that producers should be closed while they are being destructed.
This commit does not modify the existing architecture and code structure, and preserves all the logging calls in
close. At the same time, by "nullifying" the logger, it fixes the crash that is inherent in the use of logging methods during the destruction of an object.Fixes #1218.
This change is