aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-12-14 05:49:58 +0100
committerGravatar Numerlor <[email protected]>2021-01-09 20:10:54 +0100
commit73d7d748a550e644980d2604542d279472eb1b0c (patch)
tree4f1e12aeddd586b23c8fe8c768cda784f56cda8a
parentSimplify the implementation of the custom strainer (diff)
Run html parsing in an executor
The parsing may take up to a few hundred ms depending on the amount of work it has to do
-rw-r--r--bot/exts/info/doc/_cog.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py
index 07a287572..093e5cdb7 100644
--- a/bot/exts/info/doc/_cog.py
+++ b/bot/exts/info/doc/_cog.py
@@ -6,6 +6,7 @@ import re
import sys
from collections import defaultdict
from contextlib import suppress
+from functools import partial
from types import SimpleNamespace
from typing import Dict, List, NamedTuple, Optional, Union
@@ -126,7 +127,10 @@ class CachedParser:
while self._queue:
item, soup = self._queue.pop()
try:
- markdown = get_symbol_markdown(soup, item)
+ markdown = await bot_instance.loop.run_in_executor(
+ None,
+ partial(get_symbol_markdown, soup, item),
+ )
await doc_cache.set(item, markdown)
except Exception:
log.exception(f"Unexpected error when handling {item}")