detect and handle task cancellations semi-properly

This commit is contained in:
Connor Olding 2021-08-11 18:49:47 -07:00
parent 7d2637c1ad
commit d2d4917a53

View file

@ -113,7 +113,7 @@ def process_result(res, ip, check, opts: Options):
async def try_ip(db, server_ip, checks, opts: Options):
from .util import make_pooler
from asyncio import sleep
from asyncio import sleep, CancelledError
entries = []
deferred = []
@ -130,7 +130,11 @@ async def try_ip(db, server_ip, checks, opts: Options):
def finisher(done, pending):
nonlocal success
for task in done:
res, ip, check = task.result()
try:
res, ip, check = task.result()
except CancelledError:
success = False
break
entry = process_result(res, ip, check, opts)
map(maybe_put_ip, entry.addrs)
entries.append(entry)