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

Fix run_async RuntimeError #1261

Closed
wants to merge 1 commit into from
Closed

Conversation

mike1936
Copy link

@mike1936 mike1936 commented Sep 23, 2022

Description

run_async helper function raising RuntimeError sometimes when the event_loop is None.
My working case for this RuntimeError to occur is calling the run_async function inside a prefect.flow, which is just a wrapped function provided by another package named prefect for workflow orchestration.

Motivation and Context

RuntimeError raised by asyncio.get_event_loop not properly dealt by run_async function.
The event_loop is newly generated if get None then set to asyncio's event_loop

How Has This Been Tested?

NA

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@waketzheng
Copy link
Contributor

How to reproduce your bug?

And how about change run_async to be as follows:

def run_async(coro: Coroutine) -> None:
    async def runner():
        try:
            await coro
        finally:
            await connections.close_all(discard=True)

    asyncio.run(runner())

@abondar
Copy link
Member

abondar commented Jun 2, 2024

If it is actual error please describe it in issue with steps to reproduce

@abondar abondar closed this Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants