Commit f12dc5e9 authored by Petr Špaček's avatar Petr Špaček

orchestrator: support timeouts when sending queries to resolvers

parent 8e8f3042
......@@ -13,17 +13,22 @@ resolvers = [
# find query files
def find_querydirs(workdir):
i = 0
for root, dirs, files in os.walk('.'):
dirs.sort()
if not 'q.dns' in files:
continue
#print('yield %s' % root)
yield root
i += 1
if i % 10000 == 0:
print(i)
#selector.close() # TODO
with pool.Pool(
processes=8,
processes=64,
initializer=sendrecv.worker_init,
initargs=[resolvers, timeout]) as p:
p.map(sendrecv.query_resolvers, find_querydirs('.'))
for i in p.imap_unordered(sendrecv.query_resolvers, find_querydirs('.'), chunksize=1000):
pass
......@@ -34,14 +34,15 @@ def send_recv_parallel(what, selector, sockets, timeout):
# receive replies
while len(replies) != len(sockets):
events = selector.select() #timeout=timeout) # BLEH! timeout shortening
events = selector.select(timeout=timeout) # BLEH! timeout shortening
for key, _ in events:
name = key.data
sock = key.fileobj
(wire, from_address) = sock.recvfrom(65535)
assert len(wire) > 14
#assert len(wire) > 14
replies.append((name, wire))
# TIMEOUT !!!!
if not events:
break # TIMEOUT
return replies
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment