If I instantiate jsonstreams.Stream with a file descriptor that I made or am using from somewhere else, i.e.
fd = open('somefile.json', 'w')
with jsonstreams.Stream(jsonstreams.Type.object, fd=output_file) as s:
...
the file descriptor fd is closed when I leave the jsonstreams.Stream context (https://github.com/dcbaker/jsonstreams/blob/master/jsonstreams/__init__.py#L568). I'd expect the file descriptor fd to be open when I leave the context, so I can manage fd myself.
I ran into this problem using a file descriptor managed by click (https://click.palletsprojects.com/en/7.x/api/?highlight=file#click.File), where jsonstreams.Stream closed the descriptor before click was finished with it.
I had to do a hack, where I finish the jsonstreams.Stream object by calling _Stream__inst.Close() and leaving the file descriptor open so click can deal with it (https://github.com/nexB/scancode-toolkit/blob/2303-stream-json-output/src/formattedcode/output_json.py#L178)
If I instantiate
jsonstreams.Streamwith a file descriptor that I made or am using from somewhere else, i.e.the file descriptor
fdis closed when I leave thejsonstreams.Streamcontext (https://github.com/dcbaker/jsonstreams/blob/master/jsonstreams/__init__.py#L568). I'd expect the file descriptorfdto be open when I leave the context, so I can managefdmyself.I ran into this problem using a file descriptor managed by click (https://click.palletsprojects.com/en/7.x/api/?highlight=file#click.File), where
jsonstreams.Streamclosed the descriptor before click was finished with it.I had to do a hack, where I finish the
jsonstreams.Streamobject by calling_Stream__inst.Close()and leaving the file descriptor open so click can deal with it (https://github.com/nexB/scancode-toolkit/blob/2303-stream-json-output/src/formattedcode/output_json.py#L178)