google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.62k stars 322 forks source link

fix: thread-safe discovery API setup (Issues#327) #582

Closed Sumeet213 closed 1 month ago

Sumeet213 commented 1 month ago

Description of the change

Added threading support to FileServiceClient to make discovery_api thread-local.

Motivation

Fixes a threading issue where multiple threads could simultaneously access self._discovery_api, leading to bugs. Making discovery_api thread-local gives each thread its own instance.

Resolves: #327

Type of change

Bug fix

Checklist

google-cla[bot] commented 1 month ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.