diff options
| author | 2020-10-04 09:12:12 +0300 | |
|---|---|---|
| committer | 2020-10-04 09:12:12 +0300 | |
| commit | 03560d855ec407d1cfb444f392934bdb53ad5d96 (patch) | |
| tree | 845ce3e158d56d09eeef07dce2431bd57accf4d7 | |
| parent | Fix linting (diff) | |
Rename async cache instances
| -rw-r--r-- | bot/exts/info/doc.py | 7 | ||||
| -rw-r--r-- | bot/exts/utils/utils.py | 5 |
2 files changed, 5 insertions, 7 deletions
diff --git a/bot/exts/info/doc.py b/bot/exts/info/doc.py index 1fd0ee266..a847f1440 100644 --- a/bot/exts/info/doc.py +++ b/bot/exts/info/doc.py @@ -65,8 +65,7 @@ WHITESPACE_AFTER_NEWLINES_RE = re.compile(r"(?<=\n\n)(\s+)") FAILED_REQUEST_RETRY_AMOUNT = 3 NOT_FOUND_DELETE_DELAY = RedirectOutput.delete_delay -# Async cache instance for docs cog -async_cache = AsyncCache() +symbol_cache = AsyncCache() class DocMarkdownConverter(MarkdownConverter): @@ -189,7 +188,7 @@ class Doc(commands.Cog): self.base_urls.clear() self.inventories.clear() self.renamed_symbols.clear() - async_cache.clear() + symbol_cache.clear() # Run all coroutines concurrently - since each of them performs a HTTP # request, this speeds up fetching the inventory data heavily. @@ -254,7 +253,7 @@ class Doc(commands.Cog): return signatures, description.replace('ΒΆ', '') - @async_cache(arg_offset=1) + @symbol_cache(arg_offset=1) async def get_symbol_embed(self, symbol: str) -> Optional[discord.Embed]: """ Attempt to scrape and fetch the data for the given `symbol`, and build an embed from its contents. diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 278b6fefb..c006fb87e 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -43,8 +43,7 @@ Namespaces are one honking great idea -- let's do more of those! ICON_URL = "https://www.python.org/static/opengraph-icon-200x200.png" -# Async cache instance for PEPs -async_cache = AsyncCache() +pep_cache = AsyncCache() class Utils(Cog): @@ -284,7 +283,7 @@ class Utils(Cog): return pep_embed - @async_cache(arg_offset=2) + @pep_cache(arg_offset=2) async def get_pep_embed(self, ctx: Context, pep_nr: int) -> Optional[Embed]: """Fetch, generate and return PEP embed. When any error occur, use `self.send_pep_error_embed`.""" response = await self.bot.http_session.get(self.peps[pep_nr]) |