Skip to content

Python 3.9 compatibility #4168

Closed
Closed

Description

@jcrist

Opening this issue to track Python 3.9 compatibility issues.

Activity

  1. jcrist commented on Oct 14, 2020

    @jcrist
    MemberAuthor

    Currently distributed fails to start worker processes on Python 3.9 with a local cluster (at least on osx). I see

    In [3]: client = Client()
    Task exception was never retrieved
    future: <Task finished name='Task-396' coro=<_wrap_awaitable() done, defined at /opt/miniconda3/envs/prefect39/lib/python3.9/asyncio/tasks.py:678> exception=ImportError("cannot import name 'Popen' from partially initialized module 'multiprocessing.popen_spawn_posix' (most likely due to a circular import) (/opt/miniconda3/envs/prefect39/lib/python3.9/multiprocessing/popen_spawn_posix.py)")>
    Traceback (most recent call last):
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/asyncio/tasks.py", line 685, in _wrap_awaitable
        return (yield from awaitable.__await__())
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/site-packages/distributed/core.py", line 305, in _
        await self.start()
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/site-packages/distributed/nanny.py", line 295, in start
        response = await self.instantiate()
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/site-packages/distributed/nanny.py", line 378, in instantiate
        result = await self.process.start()
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/site-packages/distributed/nanny.py", line 575, in start
        await self.process.start()
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/site-packages/distributed/process.py", line 34, in _call_and_set_future
        res = func(*args, **kwargs)
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/site-packages/distributed/process.py", line 202, in _start
        process.start()
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/multiprocessing/process.py", line 121, in start
        self._popen = self._Popen(self)
      File "/opt/miniconda3/envs/prefect39/lib/python3.9/multiprocessing/context.py", line 283, in _Popen
        from .popen_spawn_posix import Popen
    ImportError: cannot import name 'Popen' from partially initialized module 'multiprocessing.popen_spawn_posix' (most likely due to a circular import) (/opt/miniconda3/envs/prefect39/lib/python3.9/multiprocessing/popen_spawn_posix.py)
  2. zanieb commented on Oct 14, 2020

    @zanieb
    Contributor

    I get the same error in the python3.9 docker image (Debain 10 - Linux version 4.19.76) so I presume this is not limited to OSX

  3. mrocklin commented on Oct 30, 2020

    @mrocklin
    Member

    cc @itamarst this seems like something that might be up your alley

  4. itamarst commented on Oct 30, 2020

    @itamarst

    Always impressed at your nerd sniping skills 😁

  5. mrocklin commented on Oct 30, 2020

    @mrocklin
    Member

    I think that my main value to society today is indexing people by technical interest

  6. mrocklin commented on Oct 30, 2020

    @mrocklin
    Member

    Also, thank you for taking a look, I appreciate it

    (I'm interpretting your 😁 as enthusiasm)

  7. itamarst commented on Oct 31, 2020

    @itamarst

    A workaround:

    >>> import multiprocessing.popen_spawn_posix
    >>> from distributed import Client
    >>> Client()
    <Client: 'tcp://127.0.0.1:41565' processes=4 threads=4, memory=8.26 GB>

    No idea what's going on yet, but I suspect it's a bug in Python.

  8. mrocklin commented on Nov 2, 2020

    @mrocklin
    Member

    Thank you for investigating this @itamarst

  9. mrocklin commented on Nov 2, 2020

    @mrocklin
    Member

    Short term, would a solution be to add that import to the appropriate file within distributed?

  10. itamarst commented on Nov 2, 2020

    @itamarst

    I would guess so, yes (on POSIX platforms, anyway).

  11. lingfeiwang commented on Nov 5, 2020

    @lingfeiwang

    And a similar command line workaround:

    dask-worker --preload-nanny multiprocessing.popen_spawn_posix

    A workaround:

    >>> import multiprocessing.popen_spawn_posix
    >>> from distributed import Client
    >>> Client()
    <Client: 'tcp://127.0.0.1:41565' processes=4 threads=4, memory=8.26 GB>
  12. mrocklin commented on Nov 5, 2020

    @mrocklin
    Member
  13. stonebig commented on Dec 20, 2020

    @stonebig

    hi all,

    The workaround proposed doesn't seem to work on Windows / Python-3.9.1 / Distributed-2020.12.0 ... I notice it may only be ok for "NOT WINDOWS"

    Any hope on this for non-windows, then Windows ?
    Any issue/fix identified/asked to cpython for next Python-3.9.2 I can follow ?

    without the POSIXpatch
    image

    with the POSIX patch (so not ok either)
    image

  14. SunMaungOo commented on Dec 25, 2020

    @SunMaungOo

    For Windows workaround

    >>> from dask.distributed import Client
    >>> import multiprocessing.popen_spawn_win32
    >>> Client()
    <Client: 'tcp://127.0.0.1:7182' processes=4 threads=8, memory=8.54 GB>
  15. stonebig commented on Dec 25, 2020

    @stonebig

    Thanks a lot @SunMaungOo , it works nicely.

  16. yannikschaelte commented on Feb 11, 2021

    @yannikschaelte

    A workaround:

    >>> import multiprocessing.popen_spawn_posix
    >>> from distributed import Client
    >>> Client()
    <Client: 'tcp://127.0.0.1:41565' processes=4 threads=4, memory=8.26 GB>

    No idea what's going on yet, but I suspect it's a bug in Python.

    Thanks @itamarst for the patch! Also solved my issue of Client() just getting stuck without any output on python 3.9.

  17. mr-september commented on Mar 2, 2021

    @mr-september

    A workaround:

    >>> import multiprocessing.popen_spawn_posix
    >>> from distributed import Client
    >>> Client()
    <Client: 'tcp://127.0.0.1:41565' processes=4 threads=4, memory=8.26 GB>

    No idea what's going on yet, but I suspect it's a bug in Python.

    PyCharm gives me an error: No module named 'popen_spawn_posix'

    Do I need to pip install something? Sorry very new to python.

  18. crusaderky commented on Mar 2, 2021

    @crusaderky
    Collaborator

    A workaround:

    >>> import multiprocessing.popen_spawn_posix
    >>> from distributed import Client
    >>> Client()
    <Client: 'tcp://127.0.0.1:41565' processes=4 threads=4, memory=8.26 GB>

    No idea what's going on yet, but I suspect it's a bug in Python.

    PyCharm gives me an error: No module named 'popen_spawn_posix'

    Do I need to pip install something? Sorry very new to python.

    What's your version of Python?

  19. crusaderky commented on Mar 2, 2021

    @crusaderky
    Collaborator

    @mr-september also, in windows you have to import multiprocessing.popen_spawn_win32 instead

  20. mr-september commented on Mar 2, 2021

    @mr-september

    What's your version of Python?

    3.9, and I'm on Ubuntu.

    but sorry I don't think I had an issue afterall, I just ignored PyCharm's warning and ran the script, things seems to have worked well.

  21. pitrou commented on Mar 16, 2021

    @pitrou
    Member

    I think this is definitely a CPython regression. Taking this upstream.

  22. mrocklin commented on Mar 16, 2021

    @mrocklin
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions