[issue10845] test_multiprocessing failure under Windows

Nick Coghlan report at bugs.python.org
Sat Jan 29 15:40:16 CET 2011


Nick Coghlan <ncoghlan at gmail.com> added the comment:

"Useless" is a rather strong word. Every change we've made to the import system (or, more accurately, the main module identification system) has been backed up with decent use cases - nearly all of the subsequent problems can be traced back to the information that gets thrown away due to the backwards compatibility concerns that forced the main module to always be called "__main__" without any record of its real name.

In the current case, it is the 3-way combination of that behaviour with the lack of real fork() functionality on Windows and an invalid assumption in multiprocessing as to the relationship between __file__ and __name__ that is causing problems.

Back on topic, Antoine's tweak looks very similar to the solution I was working on (although I hadn't made it as far as figuring out the need to change test/__main__.py to skip the execution of the top level code).

Seeing the need for that change, I think the right answer is actually to skip the find_module/load_module call completely when the module is a file called __main__.py. Such modules are implicitly part of a "if __name__ == '__main__'" clause, as that's their whole reason for existence.

The attached patch works along those lines, and I tested it by making the substantive change (the additional if clause) to an installed copy of 3.2rc1 on my Windows gaming rig.

----------
keywords: +patch
Added file: http://bugs.python.org/file20601/issue10845_mitigation.diff

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


More information about the Python-bugs-list mailing list