Skip to content

are auth credentials thread safe? #1780

@david-gang

Description

@david-gang

I have the following code. it is running from many threads for different gcs blobs:

signed_url: str = blob.generate_signed_url(
            version="v4",
            expiration=timedelta(minutes=100),
            method=method,
            content_type=content_type,
            headers=headers,
            credentials=self._signing_credentials,
        )

where the credentials are

google.authcompute_engine.IDTokenCredentials

Now the problem is that these credentials need to be refreshed in the before_request:

self._blocking_refresh(request)

but this is not thread safe

def _blocking_refresh(self, request):

    def _blocking_refresh(self, request):
        if not self.valid:
            self.refresh(request)

do i miss something?

what do you suggest ? ignoring the issue because it is normally not a problem and can just cause multiple http calls ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions