This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年10月16日 22:41 by Michael.Olson, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue10128.patch | Michael.Olson, 2010年10月20日 13:09 | Patch for Issue 10128 | ||
| Messages (13) | |||
|---|---|---|---|
| msg118905 - (view) | Author: Michael Olson (Michael.Olson) | Date: 2010年10月16日 22:41 | |
In an application with an entry point of __main__.py, multiprocessing.Pool throws the following: Traceback (most recent call last): File "<string>", line 1, in <module> File "D:\Dev\Python27\lib\multiprocessing\forking.py", line 346, in main prepare(preparation_data) File "D:\Dev\Python27\lib\multiprocessing\forking.py", line 454, in prepare assert main_name not in sys.modules, main_name AssertionError: __main__ These messages repeat as long as the application is running. Demonstration Code, must be in file named __main__.py: -------------------- import multiprocessing import time if __name__ == '__main__': pool = multiprocessing.Pool() time.sleep(2) -------------------- |
|||
| msg118969 - (view) | Author: Michael Olson (Michael.Olson) | Date: 2010年10月17日 19:36 | |
I wrapped the offending assertion in a if main_name != '__main__'. I considered not checking the module_name against built-in modules but that seemed likely to be the sort of thing being guarded against, so I left it at an exception for __main__. Ran a few trivial testing using Pool and Process and it seems to work fine. |
|||
| msg119134 - (view) | Author: Ask Solem (asksol) (Python committer) | Date: 2010年10月19日 12:36 | |
Is this on Windows? Does it work for you now? |
|||
| msg119186 - (view) | Author: Michael Olson (Michael.Olson) | Date: 2010年10月20日 03:35 | |
Sorry about that, yes, this is on Windows XP and 7, 32 bit. And with the if statement it seems to work fine. v/r -- Michael Olson |
|||
| msg119204 - (view) | Author: Michael Olson (Michael.Olson) | Date: 2010年10月20日 13:09 | |
Ummm, I think I've been unclear on where I was making changes, I changed lib\multiprocessing\forking.py to fix the issue. Patch attached. |
|||
| msg119205 - (view) | Author: Michael Olson (Michael.Olson) | Date: 2010年10月20日 13:13 | |
As a note, I didn't attach a patch at first because I was fairly sure I was kludging it into submission, but at least this makes it clear as to what I did. v/r -- Michael Olson |
|||
| msg149989 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2011年12月21日 14:22 | |
The fix from #10845 should be backported to Python 2.7 (bypassing the assertion isn't enough - you want to skip re-executing __main__ entirely) |
|||
| msg213269 - (view) | Author: Martin Dengler (mdengler) * | Date: 2014年03月12日 16:12 | |
I applied the patch from #10845 to 2.7.6 and it worked well for me. |
|||
| msg236443 - (view) | Author: Marc Schlaich (schlamar) * | Date: 2015年02月23日 13:55 | |
Please fix this. Scripts with multiprocessing bundled as wheels are broken with Python 2.7 on Windows: https://github.com/pypa/pip/issues/1891 |
|||
| msg236485 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2015年02月24日 10:06 | |
Marc's reference to pip meant I noticed something that I had missed previously - that this issue is referring specifically to the use of setuptools/pip entry points, not to the -m switch. Entry points shouldn't be hitting this if they're importing the module containing the entry point normally - #10845 specifically related to invoking multiprocessing from a module run directly with the -m switch, which was worked around in 3.2 and 3.3, and then finally fixed properly in 3.4 by the implementation of #19946 So if there's an incompatibility between multiprocessing and entry points, it would be preferable to fix it in pip/setuptools, as that will reach many more installations than just fixing multiprocessing to better tolerate that situation. |
|||
| msg254840 - (view) | Author: Marc Schlaich (schlamar) * | Date: 2015年11月18日 08:39 | |
Please see my latest comments to https://github.com/pypa/pip/issues/1891. tl;dr It is related to the -m switch as pip's wheel launcher does PYTHONPATH=script.exe python -m __main__ |
|||
| msg254872 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2015年11月19日 01:53 | |
Thanks for the investigation Marc. I'd been hesitant to backport the mitigation patch in #10845 to 2.7.x, (as it *does* represent a behavioural change), but if that code path is currently hitting an assert statement anyway, it seems reasonable to make the change for 2.7.11+ |
|||
| msg254875 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年11月19日 02:59 | |
New changeset 5d88c1d413b9 by Nick Coghlan in branch '2.7': Close #10128: don't rerun __main__.py in multiprocessing https://hg.python.org/cpython/rev/5d88c1d413b9 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:07 | admin | set | github: 54337 |
| 2015年11月19日 02:59:57 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg254875 resolution: fixed stage: resolved |
| 2015年11月19日 01:53:09 | ncoghlan | set | messages: + msg254872 |
| 2015年11月18日 08:39:47 | schlamar | set | messages: + msg254840 |
| 2015年02月24日 10:06:23 | ncoghlan | set | nosy:
+ bkabrda messages: + msg236485 |
| 2015年02月24日 02:11:54 | ned.deily | set | nosy:
+ sbt, davin |
| 2015年02月23日 13:55:54 | schlamar | set | nosy:
+ schlamar messages: + msg236443 |
| 2014年03月12日 16:12:28 | mdengler | set | messages: + msg213269 |
| 2014年03月12日 16:11:23 | mdengler | set | nosy:
+ mdengler |
| 2011年12月21日 14:22:03 | ncoghlan | set | nosy:
+ ncoghlan messages: + msg149989 |
| 2010年10月20日 13:13:13 | Michael.Olson | set | messages: + msg119205 |
| 2010年10月20日 13:09:54 | Michael.Olson | set | status: closed -> open files: + issue10128.patch messages: + msg119204 keywords: + patch resolution: not a bug -> (no value) |
| 2010年10月20日 07:20:48 | asksol | set | status: open -> closed resolution: not a bug |
| 2010年10月20日 03:35:16 | Michael.Olson | set | messages: + msg119186 |
| 2010年10月19日 12:36:51 | asksol | set | messages: + msg119134 |
| 2010年10月17日 19:36:58 | Michael.Olson | set | messages: + msg118969 |
| 2010年10月17日 02:58:53 | r.david.murray | set | nosy:
+ asksol |
| 2010年10月17日 02:26:07 | ned.deily | set | nosy:
+ jnoller |
| 2010年10月16日 22:41:50 | Michael.Olson | create | |