-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
discovery.build( ) raises ResourceWarning: unclosed <ssl.SSLSocket fd=13, #618
Comments
We're also seeing this while using other API endpoints (other than |
@berendo Could you elaborate on what |
Sure, it’s running Python with |
@berendo Thank you! This is straightforward to reproduce: from googleapiclient import discovery
client = discovery.build("dataflow", "v1b3")
|
The request to fetch the discovery doc results in the ResourceWarning. from googleapiclient import discovery
import requests
import httplib2
# Doesn't raise socket resource warning
dataflow_discovery_doc = requests.get("https://dataflow.googleapis.com/$discovery/rest?version=v1b3").json()
client = discovery.build_from_document(dataflow_discovery_doc)
# Raises socket resource warning
client = discovery.build("dataflow", "v1b3")
# Function to retrieve public discovery doc
doc = discovery._retrieve_discovery_doc("https://www.googleapis.com/discovery/v1/apis", httplib2.Http(), cache_discovery=False)
import httplib2
http = httplib2.Http()
http.request("http://example.com") I'm not sure if there's a good way to ask that the connection be closed in httplib2. I filed httplib2/httplib2#148 to ask the maintainers. From similar discussions on requests (psf/requests#3912) it may be okay to let this be. |
Since httplib2/httplib2#148 is now closed, any plans to add |
@wintermelons Thank you for the ping! It looks like httplib2 hasn't yet made a release with the change. |
FYI: httplib2 has made a new release 🙂 |
Bumping this up for the code sanity, any updates? |
This is causing a lot of disruption for us - it causes containers running Airflow tasks against GCP to consistently run out of available sockets. |
Hello folks, Apologies for leaving this unattended for so long. f this is actively causing pain you can manually call the from googleapiclient import discovery
client = discovery.build("drive", "v3")
client._http.http.close() Ideally the library should clean up |
@ramonmedeiros Can you please elaborate why did you close this issue? |
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
@busunkim96 Thank you so much for fixing this! Looking forward for the next release! |
🤖 I have created a release \*beep\* \*boop\* --- ### [1.12.2](https://www.github.com/googleapis/google-api-python-client/compare/v1.12.1...v1.12.2) (2020-09-23) ### Bug Fixes * add method to close httplib2 connections ([#1038](https://www.github.com/googleapis/google-api-python-client/issues/1038)) ([98888da](https://www.github.com/googleapis/google-api-python-client/commit/98888dadf04e7e00524b6de273d28d02d7abc2c0)), closes [#618](https://www.github.com/googleapis/google-api-python-client/issues/618) [/github.com/httplib2/httplib2/blob/9bf300cdc372938f4237150d5b9b615879eb51a1/python3/httplib2/__init__.py#L1498-L1506](https://www.github.com/googleapis//github.com/httplib2/httplib2/blob/9bf300cdc372938f4237150d5b9b615879eb51a1/python3/httplib2/__init__.py/issues/L1498-L1506) [googleapis/gapic-generator-python#575](https://www.github.com/googleapis/gapic-generator-python/issues/575) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Environment details
OS:
Linux hu3br 4.18.16-300.fc29.x86_64 add maps engine examples #1 SMP Sat Oct 20 23:24:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Python version:
Python 3.6.7
pip version:
pip 19.0.1 from /home/ramonm/git/bigtable-backups/.venv/lib/python3.6/site-packages/pip (python 3.6)
google-api-python-client
version:Name: google-api-python-client
Version: 1.7.8
Summary: Google API Client Library for Python
Home-page: http://github.com/google/google-api-python-client/
Author: Google Inc.
Author-email: None
License: Apache 2.0
Location: /home/ramonm/git/bigtable-backups/.venv/lib/python3.6/site-packages
Requires: google-auth-httplib2, six, uritemplate, google-auth, httplib2
Required-by:
Steps to reproduce
Instantiate a dataflow, v1b3 API with googleapis.discovery
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
The text was updated successfully, but these errors were encountered: