mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 02:40:11 +01:00
Fix: use sys.modules.copy() to avoid RuntimeError
use sys.modules.copy() to avoid "RuntimeError: dictionary changed size during iteration" see https://github.com/python/cpython/issues/89516 and https://docs.python.org/3.10/library/sys.html#sys.modules close https://github.com/searxng/searxng/issues/1342
This commit is contained in:
parent
a7b0b2ecbf
commit
5bcbec9b06
@ -149,7 +149,11 @@ def set_loggers(engine, engine_name):
|
|||||||
engine.logger = logger.getChild(engine_name)
|
engine.logger = logger.getChild(engine_name)
|
||||||
# the engine may have load some other engines
|
# the engine may have load some other engines
|
||||||
# may sure the logger is initialized
|
# may sure the logger is initialized
|
||||||
for module_name, module in sys.modules.items():
|
# use sys.modules.copy() to avoid "RuntimeError: dictionary changed size during iteration"
|
||||||
|
# see https://github.com/python/cpython/issues/89516
|
||||||
|
# and https://docs.python.org/3.10/library/sys.html#sys.modules
|
||||||
|
modules = sys.modules.copy()
|
||||||
|
for module_name, module in modules.items():
|
||||||
if (
|
if (
|
||||||
module_name.startswith("searx.engines")
|
module_name.startswith("searx.engines")
|
||||||
and module_name != "searx.engines.__init__"
|
and module_name != "searx.engines.__init__"
|
||||||
|
Loading…
Reference in New Issue
Block a user