-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
IsolatedAsyncioTestCase and asyncio.run no-longer call asyncio.set_event_loop #93896
Comments
import sys
import asyncio
async def run_subprocess():
proc = await asyncio.create_subprocess_shell(
"exit 0",
stdin=asyncio.subprocess.DEVNULL,
stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL,
)
await proc.wait()
print("success!")
async def amain():
await asyncio.to_thread(asyncio.run, run_subprocess())
def main():
asyncio.get_event_loop_policy().set_child_watcher(asyncio.SafeChildWatcher())
asyncio.run(amain())
if __name__ == "__main__":
sys.exit(main())
|
I know there were some efforts to deprecate |
alternatively is there still time to deprecate the child watchers system and the policy system in favor of that would be deprecating:
|
this is also broken with the PidfdChildWatcher |
Marking as potential release blocker. |
As this is a release blocker can you add @pablogsal as a reviewer for me?
https://mail.python.org/archives/list/python-dev@python.org/thread/ORCYBRP432J36LXP32IDX6KLRE7Z646V/ |
I can. Sadly, asyncio experts seem quiet. Myself, I am out of my depth here. |
The PR adds a new argument to set the current event loop policy. I propose to not add a new argument and always set the loop and when in future policy setup will be deprecated, it can be reconsidered. Also I don't think we can add or remove a new argument after beta release of 3.11 but I'll defer to @pablogsal. |
New APIs cannot be added or modified after beta freeze. Also, existing behaviour cannot be changed unless the behaviour is fundamentally wrong. |
I'm assuming that the calls to set_event_loop were removed as an intentional feature of asyncio.Runner, and ideally I'd like to keep this feature for my usage of it. However the removal of the set_event_loop calls from asyncio.run and IsolatedAsyncioTestCase appears to be to an unintended breaking change |
I am not sure I reach the same conclusion either. If I remember correctly the Runner class was extracted from some helper somewhere (may have been TaskGroup, but I am pretty sure Runner had a similar background) but I cannot find where I read this. I did however, look at the reviews of the original PR and see that the missing
Do you have a use-case where you don't want The |
Yes, I want to be able to run multiple event loops of different flavors without interacting with global state such as the policy system. Calling set_event_loop for example can join threads in the child watcher
I'm not suggesting we force the user to do this, I'm suggesting that asyncio.run call |
I am also out of my depth here. What would be the smallest change that fixes the release blocker in 3.11, without violating the feature freeze? We should have a separate discussion about the future of the policy system. |
I'll create a minimal PR to unblock the release of 3.11 soon complying with feature freeze as I commented above. @gvanrossum |
Go ahead with that PR, Kumar. |
I created #94593 which fixes this by reverting to the 3.10 and earlier behavior of setting the event loop if no loop factory was supplied. No new parameter is added so can be backport to 3.11. |
see #94597 |
…ncioTestCase (pythonGH-94593) (cherry picked from commit 14fea6b) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This comment was marked as off-topic.
This comment was marked as off-topic.
@ixenion Please be civil. This is not the place to get help, but you can find help for Python issues on discuss.python.org. |
in https://github.com/python/cpython/pull/31799/files#diff-1f2ae0f6c6010caf9d5f1c80cd6033a796ffe2b60554f5df84f554f4a08e622b the calls to
asyncio.set_event_loop()
were removed which breaks aiohttp aio-libs/aiohttp#6757 andasyncio.SafeChildWatcher
this looks like an intentional breaking change - and if it is should be documented
The text was updated successfully, but these errors were encountered: