Multiprocessing AsyncResult.get() hangs in Python 3.7.2 but not in 3.6

后端 未结 1 727
陌清茗
陌清茗 2020-12-07 02:42

I\'m trying to port some code from Python 3.6 to Python 3.7 on Windows 10. I see the multiprocessing code hang when calling .get() on the AsyncResult

相关标签:
1条回答
  • 2020-12-07 03:25

    I think this is a regression in Python 3.7.2 as described here. It seems to only affect users when running in a virtualenv.

    For the time being you can work-around it by doing what's described in this comment on the bug thread.

    import _winapi
    import multiprocessing.spawn
    multiprocessing.spawn.set_executable(_winapi.GetModuleFileName(0))
    

    That will force the subprocesses to spawn using the real python.exe instead of the one that's in the virtualenv. So, this may not be suitable if you're bundling things into an exe with PyInstaller, but it works OK when running from the CLI with local Python installation.

    0 讨论(0)
提交回复
热议问题