-
|
I am trying to call asyncio.create_subprocess_exec within a Fastapi background task, but it keeps raising a NotImplementedError. The run_subprocess function works fine when it is ran outside of Fastapi. I am running this in windows. Here is an example code and the error I am getting: Can anyone please help? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
|
Hey @rbraddev , check the note here: https://docs.python.org/3/library/asyncio-eventloop.html#running-subprocesses
Although the section https://docs.python.org/3/library/asyncio-platforms.html#subprocess-support-on-windows says that the default event loop does support subprocesses... But maybe you can use a normal |
Beta Was this translation helpful? Give feedback.
-
this is the case, ProactorEventLoop does support subprocesses, but since Kludex/uvicorn@abd6870 the auto loop chosen in uvicorn for Windows is not the windows default anymore but |
Beta Was this translation helpful? Give feedback.
-
|
thanks both. i ended up using celery to run the task. |
Beta Was this translation helpful? Give feedback.
-
|
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs. |
Beta Was this translation helpful? Give feedback.
-
|
Solution in case you're forced to use SelectorEventLoop: https://stackoverflow.com/a/76981596/1951947 |
Beta Was this translation helpful? Give feedback.
Hey @rbraddev , check the note here: https://docs.python.org/3/library/asyncio-eventloop.html#running-subprocesses
Although the section https://docs.python.org/3/library/asyncio-platforms.html#subprocess-support-on-windows says that the default event loop does support subprocesses...
But maybe you can use a normal
deffunction and run it withsubprocess.