Multiprocessing & Logging

Thibaut DIRLIK merwin.irc at gmail.com
Sat Apr 7 05:22:53 EDT 2012


Hi,

I'm currently writing a multiprocess applications with Python 3.2 and
multiprocessing module. My subprocesses will use a QueueHandler to log
messages (by sending them to the main process, which uses a QueueListener).
However, if logging is already configured when I create the subprocesses,
they will inherit the configuration, and opened file descriptors used for
logging in the main process.

However, when I tried this with a basicConfig configuration, which prints
to a file, the messages are only written once to the file. I don't
understand why. Normally, the mainprocess contains a logging handler to log
to the file. This handler will be copied into the child processes. Child
processes will then have two handlers : a QueueHandler, and a FileHandler.
They should write to the file handler and then send the message to the main
process QueueListener, which should write the message AGAIN to the
FileHandler.

But that's not the case. Any rea

How can I totally "unset" the logging configuration in child processes and
only enable the QueueHandler (foor all configured loggers, not only the
root one) ?

Thanks for your help,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120407/6ccda586/attachment.html>


More information about the Python-list mailing list