Replies: 1 comment
-
aiocache doesn't do that. Not sure if that's a deliberate choice or not, but I suspect it's of less relevance for something using an external cache. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was trying out
@cached
decorator for a simple experiment where I am invoking a co-routine withasyncio.gather(...)
. However, I could notice that in such scenarios, probably because the cache is not populated with the result, the coroutine is being called multiple times even with the same argument.Output:
I was researching around with approach of saving the unawaited result of coroutine and found out that while we cannot
await
the same coroutine multiple times, we can get around the limitation by creating a task usingasyncio.create_task(...)
.Output:
I tried to go over this repository and could only find one example with
asyncio.gather(...)
which was using locks instead. I would like to understand what am I missing with my approach and why is it not implemented withaiocache.cached
decorator? Are there scenarios where the approach I wrote above fails that I am not looking at?Beta Was this translation helpful? Give feedback.
All reactions