From 3d4df68eb875a0e7042be387bb50561b917d1e40 Mon Sep 17 00:00:00 2001 From: Numerlor <25886452+Numerlor@users.noreply.github.com> Date: Fri, 5 Mar 2021 02:09:14 +0100 Subject: Move future assignment and check outside of the try No exceptions can be raised from the two lines of code because of the data structures used, moving it out makes for flatter code. --- bot/exts/info/doc/_batch_parser.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bot/exts/info/doc/_batch_parser.py b/bot/exts/info/doc/_batch_parser.py index d80b62d88..a626008d2 100644 --- a/bot/exts/info/doc/_batch_parser.py +++ b/bot/exts/info/doc/_batch_parser.py @@ -129,12 +129,13 @@ class BatchParser: while self._queue: item, soup = self._queue.pop() markdown = None - try: - if (future := self._item_futures[item]).done(): - # Some items are present in the inventories multiple times under different symbol names, - # if we already parsed an equal item, we can just skip it. - continue + if (future := self._item_futures[item]).done(): + # Some items are present in the inventories multiple times under different symbol names, + # if we already parsed an equal item, we can just skip it. + continue + + try: markdown = await bot.instance.loop.run_in_executor(None, get_symbol_markdown, soup, item) if markdown is not None: await doc_cache.set(item, markdown) -- cgit v1.2.3