-
Notifications
You must be signed in to change notification settings - Fork 10.9k
response_httprepr memory issue fixed #4972
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4972 +/- ##
==========================================
+ Coverage 88.16% 88.52% +0.35%
==========================================
Files 162 163 +1
Lines 10487 10603 +116
Branches 1517 1527 +10
==========================================
+ Hits 9246 9386 +140
+ Misses 966 943 -23
+ Partials 275 274 -1
|
"/home/runner/work/scrapy/scrapy/scrapy/downloadermiddlewares/stats.py:3:1: F401 'scrapy.utils.response.response_httprepr' imported but unused" |
Added function for calculating headers size. Implementation of For url In this implementation DownloaderStats middleware instead of memory intensive |
So it’s still not the same size. Could you work out an implementation that returns the same as |
@Gallaecio Added counting status code related part and remaining linebreaks. |
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.
Can we now have a test that compares the result to that of len(response_httprepr(response))
, and verifies it matches for some corner cases? (empty/non-empty body, 0-1-2 headers)
Ready -> GeorgeA92@3805bab |
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.
Great job!
I would still like to address #4972 (comment), but since this is a test it is not that important.
@@ -50,6 +51,7 @@ def response_status_message(status: Union[bytes, float, int, str]) -> str: | |||
return f'{status_int} {to_unicode(message)}' | |||
|
|||
|
|||
@deprecated | |||
def response_httprepr(response: Response) -> bytes: |
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.
@wRAR FYI this function is deprecated here (and removed in 2.11) but never mentioned in the release logs (nor its removal)
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.
Great catch, I’ve logged #6207.
This code change aimed to fix memory issue #4964
Fixes #4964