import asyncio
async def eternity():
# Sleep for 60 minutes
await asyncio.sleep(3600)
print('yay!')
async def main():
try:
# timeout if function takes longer than 1 second
await asyncio.wait_for(eternity(), timeout=1.0)
except asyncio.TimeoutError:
print('timeout!')
asyncio.run(main())
# output timeout!