generative-ai-python icon indicating copy to clipboard operation
generative-ai-python copied to clipboard

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

Open Sumeet213 opened this issue 1 year ago • 0 comments

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

  • [x] I have performed a self-review of my code.
  • [x] I have added detailed comments to my code where applicable.
  • [x] I have verified that my change does not break existing code.
  • [x] My PR is based on the latest changes of the main branch.
  • [x] I am familiar with the Google Style Guide for Python.
  • [x] I have read the Contributing Guide and signed the Contributor License Agreement.

Sumeet213 avatar Oct 03 '24 22:10 Sumeet213