Skip to content

Instantly share code, notes, and snippets.

@graingert
Created July 20, 2022 12:20
Show Gist options
  • Select an option

  • Save graingert/ea2546b23b32be5a4493a9a115db2eff to your computer and use it in GitHub Desktop.

Select an option

Save graingert/ea2546b23b32be5a4493a9a115db2eff to your computer and use it in GitHub Desktop.
import asyncio
async def main():
try:
async with asyncio.timeout(0):
await asyncio.sleep(0)
except TimeoutError:
print("PASS: great a timeout is here!")
else:
print("FAILED: expected a timeout")
try:
async with asyncio.timeout(0):
await asyncio.sleep(0)
await asyncio.sleep(0)
except TimeoutError:
print("PASS: great a timeout is here!")
else:
print("FAILED: expected a timeout")
asyncio.run(main())
@graingert

Copy link
Copy Markdown
Author

prints:

FAILED: expected a timeout
PASS: great a timeout is here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment