-
Notifications
You must be signed in to change notification settings - Fork 94
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
Reduce number of HTTP connections to address CPU usage #2271
Conversation
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.
A query and some minor comments. Looks good otherwise.
ret = myCommsClient._get_data_from_url(request) | ||
self.assertEqual(ret['url'], "http://httpbin.org/get") | ||
|
||
def test_get_data_from_url_multiple(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.
Missing doc string.
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.
Added one now
exception_text = get_exception_from_html(ret.text) | ||
if exception_text: | ||
sys.stderr.write(exception_text) | ||
|
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 guess this is because we are using the same session, the client will only connect to the server once?
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.
Yes, it should use the same connection according to the requests documentation: http://docs.python-requests.org/en/master/user/advanced/
try: | ||
# dictionary containing: url, payload, method | ||
request = self._compile_url(category, func_dict, host) | ||
http_requests.append(request) |
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.
It is perhaps unfortunate that the module providing the main function is called requests
. I suppose we should use variable names that do not easily confuse with the name of that module?
Suggest something like http_request_items
(for plural) and http_request_item
for singular.
sys.stderr.write(exception_text) | ||
|
||
http_returns = [] | ||
for r in http_requests: |
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.
Please use singular of http_requests
as index for readability. E.g.:
for http_request in http_requests:
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
Fix test broken by cylc#2271.
Fix test broken by cylc#2271.
Removes redundant calls to getting suite state info and bundles some http requests into one http connection. Addresses issue in #2256 as per suggestions from @matthewrmshin.