Skip to content

Commit 0bd6a5f

Browse files
committed
docs: add warnings
1 parent 705ca7e commit 0bd6a5f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/typed_diskcache/implement/sync/lock.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ def release(self) -> None:
252252
class AsyncLock(AsyncLockProtocol):
253253
"""Lock implementation using spin-lock algorithm.
254254
255+
!!! warning
256+
If the current Python interpreter is free-threading (without GIL),
257+
using [`AsyncLock`][typed_diskcache.AsyncLock] may lead to unexpected
258+
behavior. Consider using [`SyncLock`][typed_diskcache.SyncLock]
259+
instead in such cases.
260+
255261
Assumes the key will not be evicted. Set the eviction policy to 'none' on
256262
the cache to guarantee the key is not evicted.
257263
@@ -376,6 +382,12 @@ async def __aexit__(
376382
class AsyncRLock(AsyncLock):
377383
"""Re-entrant lock implementation using spin-lock algorithm.
378384
385+
!!! warning
386+
If the current Python interpreter is free-threading (without GIL),
387+
using [`AsyncRLock`][typed_diskcache.AsyncRLock] may lead to unexpected
388+
behavior. Consider using [`SyncRLock`][typed_diskcache.SyncRLock]
389+
instead in such cases.
390+
379391
Assumes the key will not be evicted. Set the eviction policy to 'none' on
380392
the cache to guarantee the key is not evicted.
381393

src/typed_diskcache/implement/sync/semaphore.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ def __exit__(
179179
class AsyncSemaphore(AsyncSemaphoreProtocol):
180180
"""Asynchronous semaphore implementation using spin-lock algorithm.
181181
182+
!!! warning
183+
If the current Python interpreter is free-threading (without GIL),
184+
using [`AsyncSemaphore`][typed_diskcache.AsyncSemaphore] may lead to unexpected
185+
behavior. Consider using [`SyncSemaphore`][typed_diskcache.SyncSemaphore]
186+
instead in such cases.
187+
182188
Assumes the key will not be evicted. Set the eviction policy to 'none' on
183189
the cache to guarantee the key is not evicted.
184190

0 commit comments

Comments
 (0)