From 05fdf2d784bf472a655782b9b9ac20e018d9a95f Mon Sep 17 00:00:00 2001 From: Kaveen Kumarasinghe Date: Sun, 5 Feb 2023 06:59:24 -0500 Subject: [PATCH] a bit of error catching for search --- models/search_model.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/models/search_model.py b/models/search_model.py index d7b506d..2cc0f97 100644 --- a/models/search_model.py +++ b/models/search_model.py @@ -2,6 +2,7 @@ import asyncio import os import random import re +import traceback from functools import partial from bs4 import BeautifulSoup @@ -67,10 +68,14 @@ class Search: # Concatenate all the text for a given website into one string and save it into an array: documents = [] for link in links: - document = await self.loop.run_in_executor( - None, partial(self.index_webpage, link) - ) - [documents.append(doc) for doc in document] + try: + document = await self.loop.run_in_executor( + None, partial(self.index_webpage, link) + ) + [documents.append(doc) for doc in document] + except Exception as e: + traceback.print_exc() + index = GPTSimpleVectorIndex(documents)