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

If sync API is used in a running loop start a new loop in a separate thread #47

Merged
merged 1 commit into from
May 5, 2023

Conversation

jacobtomlinson
Copy link
Member

@jacobtomlinson jacobtomlinson commented May 5, 2023

Closes #41

Tweaked the async wrapping code originally taken from universalasync with an implementation from jupyter-core that starts a new loop on a separate thread if a loop is already running.

Now when using the sync API:

  • If no loop is running it will run the coroutine with asyncio.run
  • If a loop is already running (and paused because we are in a sync function) it will start a new thread with a new loop and run the coroutine there

@jacobtomlinson jacobtomlinson merged commit 7253f4e into kr8s-org:main May 5, 2023
@jacobtomlinson jacobtomlinson deleted the async-in-thread branch May 5, 2023 13:43
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.

Use sync API in event loop
1 participant