google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

new_batch_http_request() memory leak

Open Geoge-Henry opened this issue 3 years ago • 1 comments

Environment details

  • Python version: python --3.6.5
  • pip version: pip --20.3.3
  • google-api-python-client version: 1.12.8

Code example

# example
from google.oauth2 import service_account
import googleapiclient.discovery

credentials =service_account.Credentials.from_service_account_info(<service_account_info>, scopes=scopes)
google_obj = googleapiclient.discovery.build(
    service, version, credentials=credentials)
request_obj = google_obj.new_batch_http_request()
for _id, request_data in request_map.items():
    product_id = request_data["product_id"]
    token = request_data["token"]
    request_obj.add(google_obj.purchases().subscriptions().get(
        packageName=package_name,
        subscriptionId=product_id, token=token),
        request_id=_id)

request_obj.execute()

While using request_obj.execute(), I found my python process happens a memory leak. use a python tool [pympler] can check the memory leak.

Thanks!

Geoge-Henry avatar Mar 04 '21 10:03 Geoge-Henry

for those searching, here is the explanation

https://github.com/googleapis/google-api-python-client/issues/535

Barsoomx avatar Apr 10 '23 19:04 Barsoomx