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

Spawning subprocesses on Windows fails #8206

Closed
4 tasks done
zanieb opened this issue Jan 19, 2023 · 9 comments
Closed
4 tasks done

Spawning subprocesses on Windows fails #8206

zanieb opened this issue Jan 19, 2023 · 9 comments
Labels
arch:windows Related to the Windows OS bug Something isn't working upstream dependency An upstream issue caused by a bug in one of our dependencies

Comments

@zanieb
Copy link
Contributor

zanieb commented Jan 19, 2023

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Prefect documentation for this issue.
  • I checked that this issue is related to Prefect and not one of its dependencies.

Bug summary

Spawning subproceses fails with a NotImplementedError. We believe this is due to a change in the default event loop policy by Dask as this cannot be reproduced without prefect-dask installed.

For example, this affects:

  • Running flow runs with Process infrastructure on agents
  • prefect orion start

Reproduction

import prefect_dask

from prefect.infrastructure import Process

Process(command=["echo", "hello world"]).run()

Error

Traceback (most recent call last):
  File "C:\...", line 5, in <module>
    Process(command=["echo", "hello world"]).run()
  File "C:\Python310\lib\site-packages\prefect\utilities\asyncutils.py", line 230, in coroutine_wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "C:\Python310\lib\site-packages\prefect\utilities\asyncutils.py", line 181, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "C:\Python310\lib\site-packages\anyio\_core\_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "C:\Python310\lib\site-packages\anyio\_backends\_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "C:\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Python310\lib\site-packages\anyio\_backends\_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "C:\Python310\lib\site-packages\prefect\infrastructure\process.py", line 114, in run
    process = await run_process(
  File "C:\Python310\lib\site-packages\prefect\utilities\processutils.py", line 257, in run_process
    async with open_process(
  File "C:\Python310\lib\contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "C:\Python310\lib\site-packages\prefect\utilities\processutils.py", line 199, in open_process
    process = await _open_anyio_process(command, **kwargs)
  File "C:\Python310\lib\site-packages\prefect\utilities\processutils.py", line 161, in _open_anyio_process
    process = await asyncio.create_subprocess_shell(
  File "C:\Python310\lib\asyncio\subprocess.py", line 205, in create_subprocess_shell
    transport, protocol = await loop.subprocess_shell(
  File "C:\Python310\lib\asyncio\base_events.py", line 1634, in subprocess_shell
    transport = await self._make_subprocess_transport(
  File "C:\Python310\lib\asyncio\base_events.py", line 498, in _make_subprocess_transport
    raise NotImplementedError
NotImplementedError

Versions

All Python versions should be effected

Dask version information may be relevant.

Additional context

No response

@zanieb zanieb added bug Something isn't working status:triage labels Jan 19, 2023
@zanieb
Copy link
Contributor Author

zanieb commented Jan 19, 2023

Related: #8111 #8184

@zanieb zanieb added arch:windows Related to the Windows OS priority:high and removed status:triage labels Jan 19, 2023
@ccueto36
Copy link

ccueto36 commented Jan 19, 2023

I can confirm the issue. Ran the Reproduction code and getting the following error:

Traceback (most recent call last):
  File "C:\Users\ccufdet\AppData\Local\Temp\tempCodeRunnerFile.python", line 5, in <module>
    Process(command=["echo", "hello world"]).run()
  File "C:\Python310\lib\site-packages\prefect\utilities\asyncutils.py", line 230, in coroutine_wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "C:\Python310\lib\site-packages\prefect\utilities\asyncutils.py", line 181, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "C:\Python310\lib\site-packages\anyio\_core\_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "C:\Python310\lib\site-packages\anyio\_backends\_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "C:\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Python310\lib\site-packages\anyio\_backends\_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "C:\Python310\lib\site-packages\prefect\infrastructure\process.py", line 114, in run
    process = await run_process(
  File "C:\Python310\lib\site-packages\prefect\utilities\processutils.py", line 257, in run_process
    async with open_process(
  File "C:\Python310\lib\contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "C:\Python310\lib\site-packages\prefect\utilities\processutils.py", line 199, in open_process
    process = await _open_anyio_process(command, **kwargs)
  File "C:\Python310\lib\site-packages\prefect\utilities\processutils.py", line 161, in _open_anyio_process
    process = await asyncio.create_subprocess_shell(
  File "C:\Python310\lib\asyncio\subprocess.py", line 205, in create_subprocess_shell
    transport, protocol = await loop.subprocess_shell(
  File "C:\Python310\lib\asyncio\base_events.py", line 1634, in subprocess_shell
    transport = await self._make_subprocess_transport(
  File "C:\Python310\lib\asyncio\base_events.py", line 498, in _make_subprocess_transport
    raise NotImplementedError
NotImplementedError

@zanieb
Copy link
Contributor Author

zanieb commented Jan 19, 2023

Tracking in Dask at dask/distributed#7492

@zhen0 zhen0 added priority:medium upstream dependency An upstream issue caused by a bug in one of our dependencies and removed priority:high labels Mar 30, 2023
@zanieb
Copy link
Contributor Author

zanieb commented Mar 30, 2023

We've resolved this when using our CLI by setting the entrypoint again in #8184

The Dask change is blocked by tornadoweb/tornado#3173

@github-actions
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. To keep this issue open remove stale label or comment.

@github-actions
Copy link
Contributor

This issue was closed because it has been stale for 14 days with no activity. If this issue is important or you have more to add feel free to re-open it.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2023
@zanieb
Copy link
Contributor Author

zanieb commented Jul 5, 2023

@zhen0 fwiw this is still a valid issue and can be tracked by the Dask issue

@zhen0 zhen0 reopened this Jul 13, 2023
@zhen0
Copy link
Member

zhen0 commented Jul 13, 2023

Thanks @zanieb 🙏

@zanieb
Copy link
Contributor Author

zanieb commented Jul 13, 2023

Should be resolved by dask/distributed#7969 / dask/distributed#7492

@zanieb zanieb closed this as completed Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch:windows Related to the Windows OS bug Something isn't working upstream dependency An upstream issue caused by a bug in one of our dependencies
Projects
None yet
Development

No branches or pull requests

3 participants