From 8b984c9d5f7c08d3ce1219f201167c59f1b5a294 Mon Sep 17 00:00:00 2001 From: apps-lycusinc Date: Fri, 13 Mar 2026 16:55:01 +0500 Subject: [PATCH] =?UTF-8?q?Fixing=20WordNetCorpusReader=20object=20has=20n?= =?UTF-8?q?o=20attribute=20=5FLazyCorpusLoader=5F=E2=80=A6=20(#13600)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? Forces NLTK to load the corpus synchronously once, preventing concurrent tasks from triggering the lazy-loading race condition that cause Fixing WordNetCorpusReader object has no attribute _LazyCorpusLoader_… #13590 ### Type of change - [X] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: shakeel --- rag/nlp/synonym.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rag/nlp/synonym.py b/rag/nlp/synonym.py index 0956ee8e83..53a4ce1f1c 100644 --- a/rag/nlp/synonym.py +++ b/rag/nlp/synonym.py @@ -23,6 +23,13 @@ from nltk.corpus import wordnet from common.file_utils import get_project_base_directory +# Forces NLTK to load the corpus synchronously once, preventing concurrent tasks +# from triggering the lazy-loading race condition. +try: + wordnet.ensure_loaded() +except Exception: + logging.warning("Fail to load wordnet.ensure_loaded()") + class Dealer: def __init__(self, redis=None):