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

Cell execution does not seem to work when using async Python code #11526

Closed
DonJayamanne opened this issue Oct 4, 2022 · 0 comments · Fixed by #11542
Closed

Cell execution does not seem to work when using async Python code #11526

DonJayamanne opened this issue Oct 4, 2022 · 0 comments · Fixed by #11542
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Oct 4, 2022

Originally filed by ppeetteerrs here #11525
Create a Python nb with the following cells

Cell1

from asyncio import sleep, create_task, gather
from typing import Awaitable, List
from IPython.display import display
from IPython import get_ipython

def get_msg_id() -> str:
	return get_ipython().kernel.get_parent()["header"]['msg_id']

async def say_hi_to_after(x:str, tasks: Awaitable[None]):
	current_cell_msg_id = get_msg_id()
	await tasks
	get_ipython().kernel.get_parent()["header"]["msg_id"] = x
	display("HI")
	get_ipython().kernel.get_parent()["header"]["msg_id"] = current_cell_msg_id

Cell2

x = get_msg_id()

Cell3

y = say_hi_to_after(x, sleep(2))
create_task(y);

Cell4

z = say_hi_to_after(x, sleep(3))
create_task(z);

Steps:

  1. We restart the kernel and Run All (one handleExecution call with multiple cells)
  2. We press Shift+Enter quickly to run all the cells consecutively (multiple handleExecution call with one cell each)

In both cases we should see HI displayed twice as the output for the second cell.

@DonJayamanne DonJayamanne added the bug Issue identified by VS Code Team member as probable bug label Oct 4, 2022
@DonJayamanne DonJayamanne self-assigned this Oct 4, 2022
@DonJayamanne DonJayamanne added this to the October 2022 milestone Oct 6, 2022
@amunger amunger added the verified Verification succeeded label Oct 26, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
2 participants