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

GH-93896: always set event loop in asyncio.run and IsolatedAsyncioTestCase #94593

Merged
merged 5 commits into from
Jul 6, 2022

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Jul 6, 2022

Lib/asyncio/runners.py Outdated Show resolved Hide resolved
Lib/asyncio/runners.py Outdated Show resolved Hide resolved
@graingert
Copy link
Contributor

Can you copy over the test cases from my PR?

@kumaraditya303
Copy link
Contributor Author

Can you copy over the test cases from my PR?

I added a test.

Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

@kumaraditya303
Copy link
Contributor Author

LGTM, thanks for the fix!

Thanks for the reviews!

@graingert
Copy link
Contributor

graingert commented Jul 6, 2022

I think the docs should describe this change:


class Runner:
    """A context manager that controls event loop life cycle.
    The context manager always creates a new event loop,
    allows to run async functions inside it, sets the policy loop,
    and properly finalizes the loop at the context manager exit.
    If debug is True, the event loop will be run in debug mode.
    If loop_factory is passed, it is used for new event loop creation, however the
    policy loop will not be set

@kumaraditya303
Copy link
Contributor Author

kumaraditya303 commented Jul 6, 2022

I think the docs should describe this change:


class Runner:
    """A context manager that controls event loop life cycle.
    The context manager always creates a new event loop,
    allows to run async functions inside it, sets the policy loop,
    and properly finalizes the loop at the context manager exit.
    If debug is True, the event loop will be run in debug mode.
    If loop_factory is passed, it is used for new event loop creation, however the
    policy loop will not be set

This would complicate things for an average user about how policy registry works. The existing docs is clear If loop_factory is passed, it is used for new event loop creation. We can iterate over docs afterwards but let's fix the release blockers first.

@kumaraditya303 kumaraditya303 requested a review from pablogsal July 6, 2022 09:44
@pablogsal pablogsal merged commit 14fea6b into python:main Jul 6, 2022
@miss-islington
Copy link
Contributor

Thanks @kumaraditya303 for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot
Copy link

GH-94608 is a backport of this pull request to the 3.11 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants