This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients cagney, gregory.p.smith, ned.deily, vstinner
Date 2019-04-05.08:41:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1554453700.04.0.573434218252.issue36533@roundup.psfhosted.org>
In-reply-to
Content
Within the logging module we could go beyond using a WeakSet and maintain an ordering.  But we'd need to allow a way for Handler subclasses to indicate what order matters; that'd require a new API (not suitable for 3.7)

An ordering itself may be insufficient as code can implement arbitrary Handler code with cyclic graphs of handlers calling directly into other handlers such that no possible order could ever satisfy them all.

This pulls us back into "stop having multiple locks" for any code that creates relationships between handlers.  Which is good advice for Handler authors and something we should document if it isn't already.

Side note: We should also document that Handler.emit() as an API MUST be called with the Handler's lock acquired via Handler.acquire() first.  That is the undocumented contracted way logging.Logger.handle()'s code always calls into handler emit()....  The libreswan code calling other handler's emit() methods without doing that smells wrong.  But that has no relation to their current problem: Even if it did, it'd still deadlock, just sooner rather than within the other handler's emit()->flush()->acquire() call chain.

Logging library users are better off never directly calling another handler.  Put message onto queues with a dedicated thread processing those into the relevant handlers.  Only block waiting for those queued items to have been processed _after_ releasing your own lock if you want to maintain the synchronicity of logging API calls returning only after the message has been handled.
History
Date User Action Args
2019-04-05 08:41:40gregory.p.smithsetrecipients: + gregory.p.smith, vstinner, ned.deily, cagney
2019-04-05 08:41:40gregory.p.smithsetmessageid: <1554453700.04.0.573434218252.issue36533@roundup.psfhosted.org>
2019-04-05 08:41:40gregory.p.smithlinkissue36533 messages
2019-04-05 08:41:39gregory.p.smithcreate