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

fix http leak #272

Merged

Conversation

thehesiod
Copy link
Contributor

fixes #271

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

Almost good to go, thank you so much for this important fix! I'd love us to use a context manager though... 😊

@@ -94,6 +94,8 @@ def request(cls, method, url, headers, params, data, timeout, proxies, verify, m
u"Datadog's usage. We recommand upgrading it ('pip install -U requests')."
u"If you need help or have any question, please contact support@datadoghq.com"
)
finally:
Copy link
Member

Choose a reason for hiding this comment

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

Although this is 100% fine, I think I would prefer if we could use requests context manager for sessions...

we can basically wrap the entire method with:

with requests.Session() as s:
    http_adapter = requests.adapters.HTTPAdapter(max_retries=max_retries)
    s.mount('https://', http_adapter)
    
    # REST OF METHOD...

If you don't want to update that, just let me know as this is blatant nitpicking, and we can merge this as is!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me know what you think

@thehesiod
Copy link
Contributor Author

btw, for future reference, with help I found one of the leaks was due to python/cpython#4587, because this would cause a warning of unclosed socket

@thehesiod
Copy link
Contributor Author

failures don't seem related to my change

@yannmh
Copy link
Member

yannmh commented Jun 26, 2018

Thanks @thehesiod !

@yannmh yannmh merged commit f926fe6 into DataDog:master Jun 26, 2018
@yannmh yannmh mentioned this pull request Jun 26, 2018
@thehesiod thehesiod deleted the thehesiod/fix-http-client-leak branch March 8, 2019 00:03
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.

leak with 3.6.4 and datadog.api.ServiceCheck.check
3 participants