qprep: SIGINT should not result in empty queries DB
We need to handle KeyboardInterrupt so users can easily play with it.
This is not good:
$ ./qprep.py TEST < /home/pspacek/pkg/respdiff/git/response_differences/data/datafile-100k
INFO Read 10000 queries
INFO Read 20000 queries
INFO Read 30000 queries
INFO Read 40000 queries
^CProcess ForkPoolWorker-3:
Process ForkPoolWorker-1:
Process ForkPoolWorker-4:
Process ForkPoolWorker-2:
Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib64/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "./qprep.py", line 56, in wrk_process_line
wire = wire_from_text(line)
File "./qprep.py", line 105, in wire_from_text
qtype = int_or_fromtext(qtype, dns.rdatatype.from_text)
KeyboardInterrupt
Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib64/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "./qprep.py", line 56, in wrk_process_line
wire = wire_from_text(line)
File "./qprep.py", line 108, in wire_from_text
return msg.to_wire()
File "/usr/lib/python3.6/site-packages/dns/message.py", line 428, in to_wire
r.add_edns(self.edns, self.ednsflags, self.payload, self.options)
File "/usr/lib/python3.6/site-packages/dns/renderer.py", line 230, in add_edns
ednsflags, 0))
KeyboardInterrupt
Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 720, in next
item = self._items.popleft()
IndexError: pop from an empty deque
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./qprep.py", line 153, in <module>
main()
File "./qprep.py", line 147, in main
for key, wire in workers.imap(method, data_stream, chunksize=1000):
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 320, in <genexpr>
return (item for chunk in result for item in chunk)
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 724, in next
self._cond.wait(timeout)
File "/usr/lib64/python3.6/threading.py", line 295, in wait
waiter.acquire()
KeyboardInterrupt
~/pkg/respdiff/git/response_differences/respdiff (query-timeout-warning *%)$ mdb_stat -a TEST
Status of Main DB
Tree depth: 1
Branch pages: 0
Leaf pages: 1
Overflow pages: 0
Entries: 3
Status of answers
Tree depth: 0
Branch pages: 0
Leaf pages: 0
Overflow pages: 0
Entries: 0
Status of queries
Tree depth: 0
Branch pages: 0
Leaf pages: 0
Overflow pages: 0
Entries: 0
Status of stats
Tree depth: 1
Branch pages: 0
Leaf pages: 1
Overflow pages: 0
Entries: 1