Skip to content

Commit

Permalink
fix(fal_client): use asyncio.Lock instead of threading.Lock (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Oct 31, 2024
1 parent c3a22a6 commit 5acbb8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/fal_client/src/fal_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, key: str) -> None:
base_upload_url="",
expires_at=datetime.min.replace(tzinfo=timezone.utc),
)
self._lock: threading.Lock = threading.Lock()
self._lock: asyncio.Lock = asyncio.Lock()
self._url = f"{REST_URL}/storage/auth/token?storage_type=fal-cdn-v3"
self._headers = {
"Authorization": f"Key {self._key}",
Expand All @@ -110,7 +110,7 @@ async def _refresh_token(self) -> None:
)

async def get_token(self) -> CDNToken:
with self._lock:
async with self._lock:
if self._token.is_expired():
self._token = await self._refresh_token()
return self._token
Expand Down

0 comments on commit 5acbb8f

Please sign in to comment.