aio-libs / async-timeout

asyncio-compatible timeout class

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

concurrent.futures._base.CancelledError for when timeout happend.

bingchuanshi opened this issue · comments

my code just as follows
`
import asyncio
import aioping
import logging

async def do_ping(host):
try:
delay = await aioping.ping(host, 0.9) * 1000
logging.info("ping response in {:.2f}ms".format(delay))

except TimeoutError:
    logging("ping timed out")

async def ping_for_ever(host):
while True:
await asyncio.sleep(1)
await do_ping(host)

loop = asyncio.get_event_loop()
loop.run_until_complete(ping_for_ever("x.x.x.x"))
`