diff --git a/respodns/dns.py b/respodns/dns.py index d666c1d..5b8ec5d 100644 --- a/respodns/dns.py +++ b/respodns/dns.py @@ -177,8 +177,12 @@ async def try_ip(db, server_ip, checks, opts: Options): async def sync_database(db, opts: Options): - # TODO: handle addresses that were removed from respodns.ips.china. from .ips import china, blocks + + if db is None: + return + + # TODO: handle addresses that were removed from respodns.ips.china. for ips, kw in ((china, "china"), (blocks, "block_target")): for ip in ips: kwargs = dict() @@ -193,11 +197,10 @@ async def sync_database(db, opts: Options): async def main(db, filepath, checks, opts: Options): from .ip_util import read_ips from .util import make_pooler - from asyncio import sleep - from sys import stdin + from asyncio import sleep, create_task + from sys import stdin, stderr - if db is not None: - await sync_database(db, opts) + syncing = create_task(sync_database(db, opts)) def finisher(done, pending): for task in done: @@ -226,3 +229,4 @@ async def main(db, filepath, checks, opts: Options): f.close() await pooler() + await syncing