Reputation: 10060
I've found that logging I/O is a performance bottleneck of our program, so I'm thinkig of moving all logging I/O to a seperate thread. The problem is that I don't really know what's going on in the python logging module, and I'd hate to burn a day of work on something that the python logging module is already doing for me, or would be a waste of time for any other reasons. I've read the Python logging documentation and the only references to threads I've found are in reference to accessing the logger from different threads of a multithreaded application.
Does the python logging module create a seperate thread to handle I/O? If not, would it be worth my time to create a seperate thread to handle logging I/O?
Upvotes: 2
Views: 917
Reputation: 359
As mata said, python logging does not run in its own thread. However, as as 3.2 it does provide tools to make it easy to have handlers that run in their own thread, QueueHandler and QueueListener. Take a look at the "Dealing with handlers that block" section of the logging cookbook at http://docs.python.org/3.3/howto/logging-cookbook.html#dealing-with-handlers-that-block
Upvotes: 0