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 fviard
Recipients fviard
Date 2015-11-19.14:29:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1447943352.93.0.00473626885752.issue25668@psf.upfronthosting.co.za>
In-reply-to
Content
Looking at the code, this issue makes sense

in logging/__init__.py (+738):
    def handle(self, record):
        """
        Conditionally emit the specified logging record.
        Emission depends on filters which may have been added to the handler.
        Wrap the actual emission of the record with acquisition/release of
        the I/O thread lock. Returns whether the filter passed the record for
        emission.
        """
        rv = self.filter(record)
        if rv:
            self.acquire()
            try:
                self.emit(record)
            finally:
                self.release()
        return rv

Than, in the "emit()" of whatever handler used, there is first:
msg = self.format(record)

In my opinion, a possible fix would be to change this code to something like:
        rv = self.filter(record)
        if rv:
            record.formatted_msg = self.format(record)
            self.acquire()
            try:
                self.emit(record)
            finally:
                self.release()
        return rv

And then, change all the "emit()" of log handlers from:
     msg = self.format(record)
to
     msg = record.processed_msg

By not modifying the "msg" and "args" parameters of the record, all the code that would have reimplemented the standard log handler will still be working fine (even if they will still be at risk of encountering the deadlock)
History
Date User Action Args
2015-11-19 14:29:12fviardsetrecipients: + fviard
2015-11-19 14:29:12fviardsetmessageid: <1447943352.93.0.00473626885752.issue25668@psf.upfronthosting.co.za>
2015-11-19 14:29:12fviardlinkissue25668 messages
2015-11-19 14:29:12fviardcreate