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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add method to close httplib2 connections #1038

Merged
merged 3 commits into from Sep 23, 2020

Conversation

@busunkim96
Copy link
Contributor

@busunkim96 busunkim96 commented Sep 22, 2020

Fixes #618 馃

httplib2 leaves sockets open by default. This can lead to situations where programs run out of available sockets. httplib2 added a method last year to clean up connections. https://github.com/httplib2/httplib2/blob/9bf300cdc372938f4237150d5b9b615879eb51a1/python3/httplib2/__init__.py#L1498-L1506

This PR adds two ways to close http connections. The interface is intentionally similar to the proposed design for GAPIC clients. googleapis/gapic-generator-python#575

explicitly call close:

from googleapiclient import discovery

service = discovery.build("drive", "v3")
service.drives().list()
service.close()

context manager:

from googleapiclient import discovery

with discovery.build("drive", "v3") as service:
    service.drives().list()

# service.__exit__() is called which calls service.close()
@gcf-merge-on-green
Copy link

@gcf-merge-on-green gcf-merge-on-green bot commented Sep 23, 2020

Your PR has attempted to merge for 3 hours. Please check that all required checks have passed, you have an automerge label, and that all your reviewers have approved the PR

@gcf-merge-on-green
Copy link

@gcf-merge-on-green gcf-merge-on-green bot commented Sep 23, 2020

Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, or one of your required reviews was not approved. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot.

@tswast tswast requested a review from as a code owner Sep 23, 2020
tswast
tswast approved these changes Sep 23, 2020
@busunkim96 busunkim96 merged commit 98888da into googleapis:master Sep 23, 2020
3 of 4 checks passed
@busunkim96 busunkim96 deleted the context-manager-for-httplib2 branch Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants