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

asyncio timeout bug #1648

Closed
oeway opened this issue Oct 20, 2020 · 1 comment
Closed

asyncio timeout bug #1648

oeway opened this issue Oct 20, 2020 · 1 comment

Comments

@oeway
Copy link

oeway commented Oct 20, 2020

It appears that async function cannot take longer than a certain amount of time (e.g. 200ms).

For example, the following code calls a function named test_async which display a message to the output area, sleep for 1 second, then display the same message again:

import asyncio
import IPython
js_code = '''
document.querySelector("#output-area").appendChild(document.createTextNode("hello world!"));
'''

loop = asyncio.get_event_loop()

async def test_async():
  display(IPython.display.Javascript(js_code))
  await asyncio.sleep(1.0)
  display(IPython.display.Javascript(js_code))

loop.create_task(test_async())

# Current output: `hello world!`
# Expected output: `hello world!hello world!`

It should print "hello world!", sleep for 1 second and print again. However, we can only see it printed once.

If we now change the sleep time from 1 to 0.1, it works as expected. After experimenting with different values, I found the breaking point is around 0.2 (200ms).

Could you please look into this issue? @blois

@metrizable
Copy link
Contributor

@oeway Thanks for filing the issue. Since this issue was filed a while ago, there have been a number of upgrades to our ecosystem including an upgrade to ipython==7.34 and Python 3.9.

Although YMMV, the asyncio machinery appears to be working (and with various values passed to asyncio.sleep()) when utilizing asyncio.get_running_loop():

8dwiqpuLTojdGmP

If you are still experiencing the issue, please re-open and provide a minimal reproducible notebook.

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

No branches or pull requests

2 participants