Skip to content

Allow for copying file while in write mode  #20

@ghost

Description

copy the file while writing as if we finished writing

import jsonstreams


with jsonstreams.Stream(jsonstreams.Type.object, filename='foo') as s:
    for i in range(10000):
        s.write('foo', 'bar')
        if i % 1000 == 0:
            with jsonstreams.copy_from_stream(jsonstreams.Type.object, filename='foo') as copied_tmp_file_path:
                compress_and_upload_to_s3(copied_tmp_file_path)

compress_and_upload_to_s3(copied_tmp_file_path)

As you can see in the above snippet, I need to checkpoint the opened stream to s3 on fixed intervals,
I suggest to add copy_from_stream, it takes the opened stream, copy it as it's, and close it properly with a } if it is an object or a ] if it's an array.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions