[issue27837] Logging Cookbook Improvement

Niko Yasui report at bugs.python.org
Tue Aug 23 20:56:16 EDT 2016


Niko Yasui added the comment:

I see, I didn't realize that the simpler code would break under certain conditions.

While there are definitely simpler examples in other documents, I haven't been able to find any indication that there is a simpler way to do multiprocessing and logging together, either on StackOverflow or the Python docs, other than by stumbling into it accidentally while writing code for this thread. 

Since multiprocessing in Python usually requires some extra work-arounds compared to single processing solutions, I searched specifically for multiprocessing logging options. I was also not surprised that I needed a queue, since multiprocessing is complicated. IMO the docs would be more clear if there was either a simpler example with a caveat that it wouldn't work in windows, or with a small paragraph saying that after 3.2, using logging as if it were on a single process would not cause problems.

Just to clarify, my understanding is that the child loggers on separate processes pass records to the main logger, which runs on the original process, which then handles the records and writes to a file. In this way there is no problem of simultaneously writing to the same file. Is the above correct for the code I wrote?

Thanks for your patience with my inexperience. It's been a long time since I've spent so much time on learning a new module, and I think improving the docs will help other people avoid spending so much time.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27837>
_______________________________________


More information about the Python-bugs-list mailing list