Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: stream downloaded file without buffering #233

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

ktdreyer
Copy link
Contributor

@ktdreyer ktdreyer commented Feb 1, 2019

Prior to this change, treq would buffer the entire file in memory, and Python's memory usage would rise to match the entire file size.

Prior to this change, treq would buffer the entire file in memory, and
Python's memory usage would rise to match the entire file size.
@ktdreyer
Copy link
Contributor Author

ktdreyer commented Feb 1, 2019

inspired by the discussion in #116

@codecov
Copy link

codecov bot commented Feb 1, 2019

Codecov Report

Merging #233 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #233   +/-   ##
=======================================
  Coverage   98.86%   98.86%           
=======================================
  Files          26       26           
  Lines        2285     2285           
  Branches      165      165           
=======================================
  Hits         2259     2259           
  Misses         14       14           
  Partials       12       12

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d45c82...a9872df. Read the comment docs.

@twm twm self-assigned this Feb 7, 2019
Copy link
Contributor

@twm twm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you!

@@ -5,7 +5,7 @@

def download_file(reactor, url, destination_filename):
destination = open(destination_filename, 'wb')
d = treq.get(url)
d = treq.get(url, unbuffered=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, I made this change myself some time ago. It must have gotten clobbered in a merge.

@twm twm merged commit e85b37a into twisted:master Feb 7, 2019
twm added a commit to twm/treq that referenced this pull request Mar 15, 2020
bmwiedemann referenced this pull request in bmwiedemann/openSUSE Mar 25, 2020
https://build.opensuse.org/request/show/788271
by user scarabeus_iv + dimstar_suse
- version update to 20.3.0
  - Python 3.7 support. (`#228 <https://github.com/twisted/treq/issues/228>`__)
  - `treq.testing.RequestTraversalAgent` now passes its memory reactor to the `twisted.web.server.Site` it creates, preventing the ``Site`` from polluting the global reactor. (`#225 <https://github.com/twisted/treq/issues/225>`__)
  - `treq.testing` no longer generates deprecation warnings about ``twisted.test.proto_helpers.MemoryReactor``. (`#253 <https://github.com/twisted/treq/issues/253>`__)
  - The ``download_file.py`` example has been updated to do a streaming download with *unbuffered=True*. (`#233 <https://github.com/twisted/treq/issues/233>`__)
  - The *agent* parameter to `treq.request()` has been documented. (`#235 <https://github.com/twisted/treq/issues/235>`__)
  - The typ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants