Skip to content

Commit

Permalink
兼容windows系统下的文件读写,在多线程的时候,显示调用flush
Browse files Browse the repository at this point in the history
  • Loading branch information
nongbin committed May 31, 2024
1 parent 1a8bf11 commit cdd177b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions model/graph_entity/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def write(meta_node: Node):
if meta_node['timestamp']:
meta_node['timestamp'] = str(meta_node['timestamp'])
json.dump(meta_node, f, ensure_ascii=False, indent=4)
f.flush()

return Writer()

Expand All @@ -119,6 +120,7 @@ def write(self, data_node: Node):
row = [str(data_node[field]).replace("\n", " ").strip() for field in FIELD_NAMES]
line = ",".join(row)
self.file_handle.write(line + "\n")
self.file_handle.flush()

def __del__(self):
self.file_handle.flush()
Expand Down

0 comments on commit cdd177b

Please sign in to comment.