Python Logging With Multiprocessing, Root Logger Different In Windows
Solution 1:
It seems to me that this could be linked to the following platform-dependant behaviour:
16.6.3.2. Windows Since Windows lacks os.fork() it has a few extra restrictions:
(...)
Global variables
Bear in mind that if code run in a child process tries to access a global variable, then the value it sees (if any) may not be the same as the value in the parent process at the time that Process.start was called.
However, global variables which are just module level constants cause no problems.
From your question, I assume that this results in a logging.basicConfig()
call that is not reaching all your processes. A solution to this is to have your child processes to log to a Queue
(using QueueHandler
), and have a dedicated thread in your main process that will listen to the queue.
Post a Comment for "Python Logging With Multiprocessing, Root Logger Different In Windows"