google-maps-services-python icon indicating copy to clipboard operation
google-maps-services-python copied to clipboard

Client: client does not close SSL socket after request completes

Open davidbeers opened this issue 4 years ago • 1 comments

Environment details

  1. Occurs with any request using googlemaps.Client
  2. macOS Mojave
  3. Library version: 4.4.2

Steps to reproduce

  1. Instantiate a googlemaps Client
  2. Make a request
  3. Observe warning of unclosed SSL socket in console

Code example

import googlemaps

def get_lat_lng(self, address: str):
    gmaps = googlemaps.Client(key="api_key")
    geocode_result = gmaps.geocode(address)
    return geocode_result

Stack trace

ResourceWarning: unclosed <ssl.SSLSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.4', 59981), raddr=('172.217.12.10', 443)>

Impact:

Services using the googlemaps client could easily run out of sockets because of this bug.

Potential resolution:

This bug appears to be the same as https://github.com/googleapis/google-api-python-client/issues/618 If it is indeed the same there was a fix in google-api-python-client here: https://github.com/googleapis/google-api-python-client/pull/1038

davidbeers avatar Nov 13 '20 00:11 davidbeers

Having the same problem here. Any ideas on how to fix this?

luizcartolano2 avatar Nov 10 '21 17:11 luizcartolano2