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

Make ChannelQueue.get_msg true async #892

Conversation

CiprianAnton
Copy link
Contributor

ChannelQueue.get_msg is marked as async, however it's a blocking call.

Looking at https://github.com/jupyter/nbclient/blob/main/nbclient/client.py#L806, there is a call to get_msg which may block infinite. Now that code is fine, because the coroutine is being run as a background task and timeout being handled with asyncio.

However, thinking about a little bit, get_msg will block the entire thread, not giving a chance to other tasks to run.

We can easily make this method true async. I also considered asyncio.Queue, but that is not thread safe and we need it for recv_thread.

@CiprianAnton CiprianAnton marked this pull request as ready for review June 24, 2022 16:57
@CiprianAnton CiprianAnton marked this pull request as draft June 24, 2022 19:08
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2022

Codecov Report

Merging #892 (0d7d21c) into main (dee8c7a) will increase coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #892      +/-   ##
==========================================
+ Coverage   70.28%   70.44%   +0.16%     
==========================================
  Files          65       65              
  Lines        7683     7698      +15     
  Branches     1284     1287       +3     
==========================================
+ Hits         5400     5423      +23     
+ Misses       1896     1887       -9     
- Partials      387      388       +1     
Impacted Files Coverage Δ
jupyter_server/gateway/managers.py 63.52% <100.00%> (+3.72%) ⬆️
jupyter_server/services/kernels/kernelmanager.py 78.64% <0.00%> (-0.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dee8c7a...0d7d21c. Read the comment docs.

@CiprianAnton CiprianAnton marked this pull request as ready for review June 27, 2022 04:45
Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

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

The changes look good and make sense - thank you @CiprianAnton!

@blink1073 blink1073 merged commit b2669c5 into jupyter-server:main Jun 27, 2022
@blink1073
Copy link
Contributor

@meeseeksdev please backport to 1.x

meeseeksmachine pushed a commit to meeseeksmachine/jupyter_server that referenced this pull request Jun 27, 2022
blink1073 pushed a commit that referenced this pull request Jun 27, 2022
…#893)

Co-authored-by: Ciprian Anton <ciprian.anton@ni.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants