Message151792
I've been looking over this package some more, and in particular, /Lib/multiprocessing/forking.py. There's plenty I don't understand, and I do have questions, if you would be willing to indulge me.
I see that both the unix and windows codepaths define an "exit" alias for terminating the child process without performing any cleanup. On unix, this is os._exit (though it calls it directly in Popen.__init__() instead of using the alias). On Windows, it is the win32 ExitProcess() function. A quick check confirms that replacing this windows alias with "exit = sys.exit" causes flushing to occur.
So my main question is: What's wrong with using sys.exit()? I would speculate it's either because there's shared state between child and parent, or to avoid propagating SystemExit through user code in the case freeze_support() was used.
If forking.py is to terminate directly via the OS, I think it's forking.py's responsibility to flush stdout and stderr in main() on the Windows side, the way it does in Popen.__init__() on the unix side.
I also want to point out that the sys.exit() in freeze_support() is unreachable due to the exit() in main().
So it no longer surprises me that the output is not being flushed in Python 3 under windows. What surprises me is that it *is* flushed in Python 2. I remember hearing something about differences between 2 and 3 in how they handle buffering, so I'm investigating this for my own curiosity.
Incidentally, Python 2 still flushes when I remove newlines from my output text, so line buffering doesn't seem to be impacting my observations. |
|
Date |
User |
Action |
Args |
2012-01-22 23:12:57 | brandjon | set | recipients:
+ brandjon, pitrou, jnoller |
2012-01-22 23:12:57 | brandjon | set | messageid: <1327273977.15.0.790508794189.issue13812@psf.upfronthosting.co.za> |
2012-01-22 23:12:56 | brandjon | link | issue13812 messages |
2012-01-22 23:12:56 | brandjon | create | |
|