diff options
| author | 2020-12-15 00:35:12 +0100 | |
|---|---|---|
| committer | 2021-01-09 20:10:54 +0100 | |
| commit | a430f1aefdb092bc7ca2fd41bff20aedaa949f5e (patch) | |
| tree | 3b6b35702d30a37cff6d7a48c1f907281418fa89 | |
| parent | Create futures for all items in the queue (diff) | |
Wait for the inventory to be refreshed before attempting any fetching
Previously the bot returned an error if a symbol was not found while
inventories were refreshing, but we can just wait for the to finish
refreshing and then the symbol may be filled in.
A logging call to notify of the refresh being done was also added.
| -rw-r--r-- | bot/exts/info/doc/_cog.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index 0d344c363..a8642be3e 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -304,6 +304,7 @@ class DocCog(commands.Cog): ) for package in await self.bot.api_client.get('bot/documentation-links') ] await asyncio.gather(*coros) + log.debug("Finished inventory refresh.") REFRESH_EVENT.set() async def get_symbol_embed(self, symbol: str) -> Optional[discord.Embed]: @@ -316,6 +317,10 @@ class DocCog(commands.Cog): if not present also create a redis entry for the symbol. """ log.trace(f"Building embed for symbol `{symbol}`") + if not REFRESH_EVENT.is_set(): + log.debug("Waiting for inventories to be refreshed before processing item.") + await REFRESH_EVENT.wait() + symbol_info = self.doc_symbols.get(symbol) if symbol_info is None: log.debug("Symbol does not exist.") @@ -325,9 +330,6 @@ class DocCog(commands.Cog): markdown = await doc_cache.get(symbol_info) if markdown is None: log.debug(f"Redis cache miss for symbol `{symbol}`.") - if not REFRESH_EVENT.is_set(): - log.debug("Waiting for inventories to be refreshed before processing item.") - await REFRESH_EVENT.wait() markdown = await self.item_fetcher.get_markdown(symbol_info) if markdown is not None: await doc_cache.set(symbol_info, markdown) |