Skip to content

Commit 050f73c

Browse files
Merge pull request #26 from monica-veloso/moni/fix-call-with-lock
Moni/fix call with lock
2 parents e3c7899 + cd0fcea commit 050f73c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/yapcache/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.21"
1+
__version__ = "0.1.22"

src/yapcache/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def decorator(fn: Callable[P, Awaitable[R]]):
5555
async def wrapper(*args, **kwargs):
5656
key = cache_key(*args, **kwargs)
5757

58-
async def _call_with_lock():
58+
async def _call_with_lock(*args, **kwargs):
59+
key = cache_key(*args, **kwargs)
5960
async with lock(key + ":lock"):
6061
found = await cache.get(
6162
key
@@ -80,7 +81,7 @@ async def _call_with_lock():
8081
if isinstance(found, CacheItem):
8182
status = CacheStatus.HIT
8283
if found.is_stale and key not in update_tasks:
83-
task = asyncio.create_task(_call_with_lock())
84+
task = asyncio.create_task(_call_with_lock(*args, **kwargs))
8485
update_tasks[key] = task # TODO: acho que tem problema
8586
task.add_done_callback(lambda _: update_tasks.pop(key))
8687
status = CacheStatus.STALE

0 commit comments

Comments
 (0)