concurrent.futures._base.CancelledError for when timeout happend.
bingchuanshi opened this issue · comments
Bingchuan Shi commented
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"))
`