detect and handle task cancellations semi-properly
This commit is contained in:
parent
7d2637c1ad
commit
d2d4917a53
1 changed files with 6 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue