Message247463
Context is crucial. The Python documentation is not wrong, but doesn't belabour the point that it refers to the most common, single-process case. The problem you encountered is not specific to logging: you need to understand all aspects of how forking works and how Python works within the framework of POSIX and forking. It's a non-trivial topic and too much to go into here - suffice to say that in order to get the result you expect, you need (as I said in an earlier comment) to configure logging in code that is called in each process of a multiple-process setup. If you add two handlers to a logger, one before forking and one after forking, then the child process might behave as expected, but logging from the parent process could output multiple copies of the same message. If you don't do any logging in the parent, that might be OK, but it still doesn't feel like the right approach.
You might find it helpful to read my 2010 blog post about logging and multiprocessing:
http://plumberjack.blogspot.co.uk/2010/09/using-logging-with-multiprocessing.html
AFAIK nothing fundamental has changed since then to invalidate the overall thrust of that post. |
|
Date |
User |
Action |
Args |
2015-07-27 12:22:42 | vinay.sajip | set | recipients:
+ vinay.sajip, ericg97477 |
2015-07-27 12:22:42 | vinay.sajip | set | messageid: <1437999762.36.0.325073011076.issue24717@psf.upfronthosting.co.za> |
2015-07-27 12:22:42 | vinay.sajip | link | issue24717 messages |
2015-07-27 12:22:41 | vinay.sajip | create | |
|