vscode-pyolite
vscode-pyolite copied to clipboard
`time.sleep(...)` fails to suspend execution for indicated number of seconds.
Expected behavior:
When importing Python's time module and using the sleep() function, I expect to suspend execution of the calling thread for the given number of seconds.
Experienced behavior: 42 seconds passed in the blink of an eye. I knew it was a special number, but not that special! ☺
Reproducible example:
import time
print("The meaning of life...")
time.sleep(42)
print("...is learning the superpower of patience.")

This is caused by https://github.com/pyodide/pyodide/issues/1720
🤔 the semantic colorization in that screenshot looks off. Possibly worth filing an issue on Pylance?
An alternative to time.sleep() is to use await asyncio.sleep():
import asyncio
print("The meaning of life...")
await asyncio.sleep(42)
print("...is learning the superpower of patience.")
🤔 the semantic colorization in that screenshot looks off. Possibly worth filing an issue on Pylance?
@joyceerhl 😄 Upvotes appreciated! Rich is on it: https://github.com/microsoft/pylance-release/issues/1874
@jtpio : Thank you! Will use the workaround in my notebook example.