Skip to content

Instantly share code, notes, and snippets.

@graingert
Created July 20, 2022 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graingert/ea2546b23b32be5a4493a9a115db2eff to your computer and use it in GitHub Desktop.
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
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