ChunkedFile
A file handle that groups subsequence writes together and periodically writes
them as separate files. Useful for file systems like GCS FUSE that do not
support file appending. Pathlib can be patched to replace files opened in
append mode with chunked files, so external libraries need not be changed.
Usage
Using ChunkedFile
:
import time
import chunkedfile
with chunkedfile.ChunkedFile('filename.txt', 600) as f:
f.write('Lorem\n')
time.sleep(1000)
f.write('Ipsum\n')
f.write('Dolor\n')
f.write('Sit\n')
Using pathlib.Path
:
import time
import pathlib
import chunkedfile
chunkedfile.patch_pathlib_append(600)
with pathlib.Path('filename.txt').open('a') as f:
f.write('Lorem\n')
f.write('Ipsum\n')
time.sleep(1000)
f.write('Dolor\n')
f.write('Sit\n')