def as_bulk_resolve(candidates, threads=50):
"""
Resolve a list of IPs to AS information.
Returns a map of each result as a tuple of (ASN, owner) keyed to
its candidate. Returns None if no ASN could be found or (ASN,
None) if an ASN was found but no owner is available.
WARNING: This function will create a pool of up to 'threads'
threads.
"""
result = {}
pool = multiprocessing.pool.ThreadPool(
processes=min(len(candidates), threads))
for ip, as_ in pool.imap(
__asresolve__,
candidates,
chunksize=1):
result[ip] = as_
pool.close()
return result
评论列表
文章目录