def end_flush(self):
"""
Write buffered contents to disk.
There's no need to perform this write
in a seperate thread.
"""
def flush():
if len(self.buffer) == 0:
return defer.succeed
log_path = os.path.join(self.out_dir, "%s-scan.json" % (datetime.datetime.utcnow().isoformat()))
wf = open(log_path, "w")
try:
json.dump(self.buffer, wf, sort_keys=True)
finally:
wf.close()
return threads.deferToThread(flush)
评论列表
文章目录