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

Reduce number of HTTP connections to address CPU usage #2271

Merged
merged 6 commits into from
May 10, 2017

Conversation

dvalters
Copy link
Contributor

@dvalters dvalters commented May 8, 2017

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.

@dvalters dvalters changed the title Reduce number of HTTP conncetions to address CPU usage Reduce number of HTTP connections to address CPU usage May 8, 2017
@dvalters dvalters self-assigned this May 8, 2017
Copy link
Contributor

@matthewrmshin matthewrmshin left a 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):
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing doc string.

Copy link
Contributor Author

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)

Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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:
Copy link
Contributor

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:

Copy link
Member

@hjoliver hjoliver 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

@hjoliver hjoliver merged commit afe5ba6 into cylc:master May 10, 2017
matthewrmshin added a commit to matthewrmshin/cylc-flow that referenced this pull request May 11, 2017
matthewrmshin added a commit to matthewrmshin/cylc-flow that referenced this pull request May 11, 2017
@hjoliver hjoliver added this to the cylc-7.4.0 milestone May 15, 2017
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.

3 participants