-
Notifications
You must be signed in to change notification settings - Fork 8
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
Async support #23
Async support #23
Conversation
Codecov Report
@@ Coverage Diff @@
## master #23 +/- ##
==========================================
- Coverage 71.64% 71.63% -0.01%
==========================================
Files 27 27
Lines 2084 2073 -11
==========================================
- Hits 1493 1485 -8
+ Misses 591 588 -3
Continue to review full report at Codecov.
|
|
||
|
||
def run_sync(coro_method): | ||
return asyncio.get_event_loop().run_until_complete(coro_method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is a pytest-asyncio plugin which can streamline writing tests for async code.
To record our conversation from other venues, I am mostly OK with deduplicating the code paths by only having async kernel management methods. However, I would like to know:
|
I think to deal with the Qt event loop + asyncio you need an extra layer of coordination, something like what's provided by this package: |
Thanks Carlos. Have you used that before? Do you have a feeling for how hard it would be if you needed to use async/await code for things like launching kernels? |
Nop, I saw it in Reddit some time ago and saved the reference in case we needed to use it in Spyder.
It doesn't seem that hard to use, at least according to its examples. But I'm really not sure. So there won't be a way to ask for synchronous launching of kernels in the future? I mean, that would allow qtconsole to keep working without problems. |
I think it's easy enough if you want to run the async calls synchronously - you can call something like |
Right, I forgot about it. |
Start and restart are working using async/await. Switch to single (async) launch method. Removed support for Python 3.4 so we could just focus on 3.5+ with async/await. Updated tests after rebase of launch-params PR.
@takluyver - the momentum is increasing to get kernel-mgmt into jupyter_server. Since we definitely want async kernel management support, and given we've been able to show existing (sync) applications could utilize this async-based library, is there anything else preventing this being merged? When migrating to jupyter_server, I'd kinda like async support to part of that initial effort. |
No, go for it. At some point I think it would be a good idea to use the pytest-asyncio plugin for the tests, but that's not high priority. |
Got start and restarts working. I've switched to a single launch method that is defined as aync. This is because we can't have both due to the way restarts work (calling the (previously synchronous) launch method and we shouldn't require providers to implement both forms - especially when async support is required to be implemented deep in the provider (i.e., it may not be practical to implement both forms). Since async support is clearly warranted and in line with future directions, we should adopt at as the single mechanism.
By switching to a single method, providers that ONLY support synchronous operations can still implement their provider that way, but will need to invoke the KernelFinder (or provider's) launch method using something like the following (from tests/utils.py):
Removed support for Python 3.4 so we could just focus on 3.5+ with async/await.
The experimental notebook branch has been modified to make calls with knowledge that async support is implemented.