def run(self):
print "Starting thread to write results into the file %s..." % self._out_file_path
with open(self._out_file_path, 'wt', buffering=1) as csvfile:
#writer = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_NONE)
dict_writer = csv.DictWriter(csvfile, self._fieldnames)
dict_writer.writeheader()
while not self._exit.is_set():
while True:
queue_item=None
try:
queue_item = self._queue.get(True, 5)
except Queue.Empty:
break
dict_writer.writerow(queue_item)
self._counter += 1
self._queue.task_done()
if self._counter % 10 == 0:
print "Analyzed %d pairs..." % self._counter
print "Finishing file writer thread..."
评论列表
文章目录