Davin Potts added the comment:
Closing per the feedback of the OP and secondary contributor to the issue.
Kudos to the reporters for such nice follow-up.
--
nosy: +davin
resolution: - not a bug
stage: - resolved
status: open - closed
___
Python
Ari Koivula added the comment:
Guarding the initialization is indeed correct and works, but log_to_stderr
adding the handler multiple times is still annoying. Especially as you probably
do want it to be called for child processes (at least on windows) and it might
be called during
Ari Koivula added the comment:
Actually, multiprocessing.forking.prepare does call log_to_stderr on windows.
While debugging the double handler issue I somehow came to the conclusion that
it didn't, but it seems to work just fine now. I must have been doing something
weird like creating the
paul j3 added the comment:
I had noticed the `global _log_to_stderr` in `util.log_to_stderr()`, but hadn't
taken time to track down where it is used.
Not only is it passed from the 'util' module to the 'forking' one, but it is
also passed via a piped pickle from parent to child process.
Ari Koivula added the comment:
I encountered this problem on Python 3.2.5 on Windows and don't think a vague
warning about initializing modules is a proper solution. A better solution
would be to simply not add multiple handlers, even if log_to_stderr is called
more than once.
--
paul j3 added the comment:
I added a print line to a 'windows' example from the documentation:
from multiprocessing import Process
print 'importing multiprocessing'
def foo():
print 'hello'
p = Process(target=foo)
p.start()
Run with Python 2.7.0 on linux I get
paul j3 added the comment:
The documentation currently warns
https://docs.python.org/2/library/multiprocessing.html#windows
Safe importing of main module
Make sure that the main module can be safely imported by a new Python
interpreter without causing unintended side effects (such a
Mark Lawrence added the comment:
@paul j3 can you prepare a patch for this?
--
nosy: +BreamoreBoy
type: - behavior
versions: +Python 2.7, Python 3.4, Python 3.5
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12954
paul j3 added the comment:
It will take a while to reconstruct the circumstances behind this issue. I
think I was working through some online class examples, working in the Eclipse
pydev environment. Currently I'm mostly working in linux, and not doing much
with multiprocessing. Looks like
New submission from paul j3 ajipa...@gmail.com:
The Windows programming guidelines for the multiprocessing module documentation
should include a warning that any logging initialization should be protected by
the 'if __name__' block. Otherwise you will get duplicate logging entries for
the
10 matches
Mail list logo