Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

Changes in Version 4.3.3
------------------------

- Fixed a performance regression in :meth:`~gridfs.GridOut.download_to_stream`
and :meth:`~gridfs.GridOut.download_to_stream_by_name` by reading in chunks
instead of line by line.


Changes in Version 4.3 (4.3.2)
------------------------------

Expand Down
10 changes: 8 additions & 2 deletions gridfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,10 @@ def download_to_stream(
Added ``session`` parameter.
"""
with self.open_download_stream(file_id, session=session) as gout:
for chunk in gout:
while True:
chunk = gout.readchunk()
if not len(chunk):
break
destination.write(chunk)

@_csot.apply
Expand Down Expand Up @@ -977,7 +980,10 @@ def download_to_stream_by_name(
Added ``session`` parameter.
"""
with self.open_download_stream_by_name(filename, revision, session=session) as gout:
for chunk in gout:
while True:
chunk = gout.readchunk()
if not len(chunk):
break
destination.write(chunk)

def rename(
Expand Down