-
Notifications
You must be signed in to change notification settings - Fork 140
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
Conversation
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.
inspired by the discussion in #116 |
Codecov Report
@@ 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.
|
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
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
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.