-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Simplify time caching in DATE: header formatting (#2176) #2180
Conversation
Will fix tests and formatting slightly later. Please review my idea. |
aiohttp/web_response.py
Outdated
if now != _cached_current_datetime: | ||
# Weekday and month names for HTTP date/time formatting; | ||
# always English! | ||
# Tuples are contants stored in codeobject! |
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.
ConStants
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.
Lets kill TimeService.
aiohttp/web_response.py
Outdated
|
||
_cached_current_datetime = None | ||
_cached_formatted_datetime = None | ||
def get_formatted_datetime(): |
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.
I think this should be helper method.
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.
Do you mean @staticmethod
?
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.
Okay, classmethod
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.
just function in helpers.py
I have no strong opinion for the PR. |
Codecov Report
@@ Coverage Diff @@
## master #2180 +/- ##
=========================================
+ Coverage 97.19% 97.2% +<.01%
=========================================
Files 39 39
Lines 8227 8184 -43
Branches 1435 1433 -2
=========================================
- Hits 7996 7955 -41
+ Misses 102 101 -1
+ Partials 129 128 -1
Continue to review full report at Codecov.
|
Please wait. I'm writing test for correct caching in the new function. |
And I have found and fixed significant bug (!) in my implementation. |
Well, I consider this can be merged right now. |
tests/test_helpers.py
Outdated
mock_gmtime.side_effect = gmtime | ||
|
||
mock_time.return_value = 1234567890.998 | ||
assert helpers.rfc822_formatted_time() == 'Fri, 13 Feb 2009 23:31:30 GMT' |
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.
Friday 13 :)
Ping |
…ng (#2176) Thanks for @greg-barnett for the code I picked-up.
@@ -402,11 +400,6 @@ def keep_alive(self): | |||
"""Is keepalive enabled by client?""" | |||
return not self._message.should_close | |||
|
|||
@property | |||
def time_service(self): |
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.
Wonder if that would be a breaking change.
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.
I don't understand what you mean.
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.
Should be fine. As I remember time_service is not documented
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.
@socketpair Removing public attribute/method/property may break someone's code who depends on it.
@fafhrd91 Ah, cool then.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
What do these changes do?
Are there changes in behavior for the user?
Related issue number
Issue #2176
Checklist
CONTRIBUTORS.txt
changes
folder<issue_id>.<type>
for example (588.bug)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.