aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-12-11 23:42:36 +0100
committerGravatar Numerlor <[email protected]>2020-12-15 05:02:10 +0100
commitf6805c397c47d7dbfc2f38998c7de3556de69b42 (patch)
tree67f333d832282a59a3d661c4f51989d7e0b5c2b6
parentRemove internal CachedParser result cache (diff)
Ensure only one future is created for each doc_item
Previously in case get_markdown for an item ran twice, the one that ran second would overwrite the future created by the first one, potentially causing the coro to wait for it infinitely as _parse_queue would only be able to set the last future
-rw-r--r--bot/exts/info/doc/_cog.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py
index d2bbf8c57..78d9c6b9b 100644
--- a/bot/exts/info/doc/_cog.py
+++ b/bot/exts/info/doc/_cog.py
@@ -106,8 +106,9 @@ class CachedParser:
self._parse_task = asyncio.create_task(self._parse_queue())
self._move_to_front(doc_item)
- self._item_futures[doc_item] = item_future = asyncio.Future()
- return await item_future
+ if doc_item not in self._item_futures:
+ self._item_futures[doc_item] = bot_instance.loop.create_future()
+ return await self._item_futures[doc_item]
async def _parse_queue(self) -> None:
"""