diff options
| author | 2021-01-13 23:18:33 +0100 | |
|---|---|---|
| committer | 2021-01-14 05:01:14 +0100 | |
| commit | 7342510667ea159fcc83927cb9caee14661c12a8 (patch) | |
| tree | a97e88272c22ad9d256be0b36fddca4f62d70607 | |
| parent | Reuse the redis key instead of creating a new string for the expires set (diff) | |
Set the user_requested attribute at the start of the coroutine
A context switch may occur when we're waiting for the web page response,
during which a clear could be triggered. If the event is not set before
that we could end up with the dictionary changing sizes, or if a copy
was made, a future that'd never finish as it'd be
cleared from the queue and the futures dict
| -rw-r--r-- | bot/exts/info/doc/_batch_parser.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/bot/exts/info/doc/_batch_parser.py b/bot/exts/info/doc/_batch_parser.py index ebae6efb8..4a6d9b544 100644 --- a/bot/exts/info/doc/_batch_parser.py +++ b/bot/exts/info/doc/_batch_parser.py @@ -108,6 +108,7 @@ class BatchParser: Not safe to run while `self.clear` is running. """ + self._item_futures[doc_item].user_requested = True if (symbols_to_queue := self._page_symbols.get(doc_item.url)) is not None: async with bot.instance.http_session.get(doc_item.url) as response: soup = BeautifulSoup(await response.text(encoding="utf8"), "lxml") @@ -123,7 +124,6 @@ class BatchParser: with suppress(ValueError): # If the item is not in the list then the item is already parsed or is being parsed self._move_to_front(doc_item) - self._item_futures[doc_item].user_requested = True return await self._item_futures[doc_item] async def _parse_queue(self) -> None: |