mirror of https://github.com/D4-project/d4-core
fix: [worker 8] fix save_file
parent
b530c67825
commit
336fc7655a
|
@ -152,7 +152,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
||||||
# save data on disk
|
# save data on disk
|
||||||
if save_to_file:
|
if save_to_file and b'\n' in data[b'message']:
|
||||||
new_date = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
new_date = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
||||||
# check if a new rotation is needed
|
# check if a new rotation is needed
|
||||||
if ( new_date[0:8] != date_file[0:8] ) or ( time.time() - time_file > rotation_save_cycle ):
|
if ( new_date[0:8] != date_file[0:8] ) or ( time.time() - time_file > rotation_save_cycle ):
|
||||||
|
@ -160,7 +160,7 @@ if __name__ == "__main__":
|
||||||
rotate_file = True
|
rotate_file = True
|
||||||
|
|
||||||
# file rotation
|
# file rotation
|
||||||
if rotate_file and b'\n' in data[b'message']:
|
if rotate_file:
|
||||||
end_file, start_new_file = data[b'message'].rsplit(b'\n', maxsplit=1)
|
end_file, start_new_file = data[b'message'].rsplit(b'\n', maxsplit=1)
|
||||||
# save end of file
|
# save end of file
|
||||||
with open(save_path, 'ab') as f:
|
with open(save_path, 'ab') as f:
|
||||||
|
|
Loading…
Reference in New Issue