Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error for multiprocessing in 2.7rc2 on Windows #53390

Closed
ot mannequin opened this issue Jul 2, 2010 · 8 comments
Closed

Import error for multiprocessing in 2.7rc2 on Windows #53390

ot mannequin opened this issue Jul 2, 2010 · 8 comments
Assignees
Labels
build The build process and cross-build release-blocker type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ot
Copy link
Mannequin

ot mannequin commented Jul 2, 2010

BPO 9144
Nosy @loewis, @brettcannon, @pfmoore, @benjaminp, @merwok
Files
  • mp.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/benjaminp'
    closed_at = <Date 2010-07-03.12:26:47.601>
    created_at = <Date 2010-07-02.13:43:14.459>
    labels = ['build', 'type-crash', 'release-blocker']
    title = 'Import error for multiprocessing in 2.7rc2 on Windows'
    updated_at = <Date 2010-07-03.12:26:47.600>
    user = 'https://bugs.python.org/ot'

    bugs.python.org fields:

    activity = <Date 2010-07-03.12:26:47.600>
    actor = 'jnoller'
    assignee = 'benjamin.peterson'
    closed = True
    closed_date = <Date 2010-07-03.12:26:47.601>
    closer = 'jnoller'
    components = ['Build']
    creation = <Date 2010-07-02.13:43:14.459>
    creator = 'ot'
    dependencies = []
    files = ['17849']
    hgrepos = []
    issue_num = 9144
    keywords = ['patch']
    message_count = 8.0
    messages = ['109109', '109125', '109163', '109164', '109165', '109169', '109178', '109180']
    nosy_count = 7.0
    nosy_names = ['loewis', 'brett.cannon', 'paul.moore', 'benjamin.peterson', 'jnoller', 'eric.araujo', 'ot']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue9144'
    versions = ['Python 2.7']

    @ot
    Copy link
    Mannequin Author

    ot mannequin commented Jul 2, 2010

    With a fresh install from python-2.7rc2.amd64.msi (rc1 is also affected) multiprocessing gives the following error:

    Python 2.7rc2 (r27rc2:82154, Jun 22 2010, 21:22:29) [MSC v.1500 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import multiprocessing
    >>> multiprocessing.Pool()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Python27\lib\multiprocessing\__init__.py", line 227, in Pool
        return Pool(processes, initializer, initargs, maxtasksperchild)
      File "C:\Python27\lib\multiprocessing\pool.py", line 89, in __init__
        self._setup_queues()
      File "C:\Python27\lib\multiprocessing\pool.py", line 181, in _setup_queues
        from .queues import SimpleQueue
      File "C:\Python27\lib\multiprocessing\queues.py", line 22, in <module>
        from multiprocessing.synchronize import Lock, BoundedSemaphore, Semaphore, Condition
      File "C:\Python27\lib\multiprocessing\synchronize.py", line 22, in <module>
        from multiprocessing.forking import assert_spawning, Popen
      File "C:\Python27\lib\multiprocessing\forking.py", line 158, in <module>
        from ._multiprocessing import win32, Connection, PipeConnection
    ImportError: No module named _multiprocessing

    I noticed that _multiprocessing.lib is not in Lib/multiprocessing/ but in libs/, so I don't know why there is a relative import here.
    Changing all the occurrences to
    from _multiprocessing import ...
    everything works fine.

    @ot ot mannequin added stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump labels Jul 2, 2010
    @merwok merwok added build The build process and cross-build and removed stdlib Python modules in the Lib dir labels Jul 2, 2010
    @benjaminp
    Copy link
    Contributor

    Martin, any ideas?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jul 3, 2010

    Here is the problem: there is no module multiprocessing._multiprocessing; _multiprocessing is a global module. However, multiprocessing/init.py imports _multiprocessing, providing multiprocessing._multiprocessing as a valid attribute. sys.modules['multiprocessing._multiprocessing'] is None.

    Now, on Windows, for some reason,

    from ._multiprocessing import win32

    is used. In 2.6, this used to work. In 2.7, due to r81380, it stopped working (i.e. if I revert r81380, it works again). Adding Brett to the nosy list, as he made this change.

    @pfmoore
    Copy link
    Member

    pfmoore commented Jul 3, 2010

    Martin's analysis (and the description of the commit he refers to) indicates that the correct fix is Cuiseppe's suggestion to change the relative imports to absolute:

    from _multiprocessing import ...

    as the previous code was only working because, as a result of the bug fixed in r81380, from ._multiprocessing was falling back to this form anyway.

    @pfmoore
    Copy link
    Member

    pfmoore commented Jul 3, 2010

    Here's a patch implementing the suggested change. test_multiprocessing passes. I am just running the full test suite now.

    @pfmoore
    Copy link
    Member

    pfmoore commented Jul 3, 2010

    Full test suite also looks OK.

    @jnoller
    Copy link
    Mannequin

    jnoller mannequin commented Jul 3, 2010

    the patch looks good to me - unless someone beats me to it, I'm going to commit it shortly to fix 2.7

    @jnoller
    Copy link
    Mannequin

    jnoller mannequin commented Jul 3, 2010

    Pushed it in r82489 - worked for me on Linux and OS/X. Please let me know if anything else comes up.

    @jnoller jnoller mannequin closed this as completed Jul 3, 2010
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    build The build process and cross-build release-blocker type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants