Skip to content

Conversation

@gpshead
Copy link
Member

@gpshead gpshead commented Nov 11, 2017

The logging RLock instances may exist but the threading.RLock class
itself has already been emptied causing a
Exception TypeError: "'NoneType' object is not callable" in <function _removeHandlerRef ..."
to be printed to stderr on process termination.

This catches that exception and ignores it because there is absolutely
nothing we can or should do about it from the context of a weakref
handler called from the gc context.

https://bugs.python.org/issue21149

@gpshead gpshead changed the title [2.7] bpo21149: Workaround a GC finalization bug in logging. [2.7] bpo-21149: Workaround a GC finalization bug in logging. Nov 11, 2017
The logging RLock instances may exist but the threading.RLock class
itself has already been emptied causing a
Exception TypeError: "'NoneType' object is not callable" in <function _removeHandlerRef ..."
to be printed to stderr on process termination.

This catches that exception and ignores it because there is absolutely
nothing we can or should do about it from the context of a weakref
handler called from the gc context.
@gpshead gpshead force-pushed the issue21149_removeHandlerRef_workaround branch from 4fb5489 to bb43dbc Compare November 11, 2017 01:13
@gpshead gpshead requested a review from vsajip November 11, 2017 01:23
@gpshead
Copy link
Member Author

gpshead commented Nov 11, 2017

This is non-deterministic as it depends on the order the garbage collection and finalization happen in, creating a unittest for this doesn't make much sense.

finally:
release()
except TypeError:
# https://bugs.python.org/issue21149 - If the RLock object behind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would sys.is_finalizing() help here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, forgot, this is 2.7.

@gpshead gpshead merged commit e84f6d3 into python:2.7 Nov 11, 2017
@gpshead gpshead deleted the issue21149_removeHandlerRef_workaround branch November 11, 2017 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants