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) #583

Closed Sumeet213 closed 4 weeks 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