Token refresh uses blocking I/O in async function #245
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: cleanup
An internal cleanup or hygiene concern.
Bug Description
Token refresh in the async
Client
class uses therequests.Request
transport of the google auth libraryalloydb-python-connector/google/cloud/alloydb/connector/client.py
Lines 186 to 188 in 6cc4c8e
This means it is doing blocking I/O on the asyncio loop. At the minimum, the fetch seems like it needs to be delegated to a thread with
asyncio.to_thread
.For reference, google-auth-library-python does have some baking experimental APIs for async
https://github.com/googleapis/google-auth-library-python/blob/main/google/auth/transport/_aiohttp_requests.py
https://github.com/googleapis/google-auth-library-python/blob/main/google/auth/_default_async.py
However, assuming using the experimental APIs was ok, it's probably still not ready for general use because at least, impersonated credentials don't yet have an async version (in certain token refresh logic I've written, I use the async APIs for normal creds and
to_thread
for impersonated, but it seems too complicated for this library).https://github.com/googleapis/google-auth-library-python/blob/main/google/auth/impersonated_credentials.py
Example code (or command)
No response
Stacktrace
No response
Steps to reproduce?
...
Environment
Additional Details
No response
The text was updated successfully, but these errors were encountered: