Skip to content

Commit b3bf5c2

Browse files
author
Gerit Wagner
committed
dblp: handle timeout gracefully
1 parent 2d197b4 commit b3bf5c2

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

colrev/packages/dblp/src/dblp.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from multiprocessing import Lock
99
from pathlib import Path
1010

11+
import requests # pylint: disable=colrev-search-source-requests-import
1112
from pydantic import BaseModel
1213
from pydantic import Field
1314

@@ -20,6 +21,7 @@
2021
import colrev.record.record_similarity
2122
import colrev.search_file
2223
import colrev.utils
24+
from colrev.constants import Colors
2325
from colrev.constants import Fields
2426
from colrev.constants import FieldValues
2527
from colrev.constants import RecordState
@@ -345,17 +347,22 @@ def search(self, rerun: bool) -> None:
345347
logger=self.logger,
346348
verbose_mode=self.verbose_mode,
347349
)
348-
if self.search_source.search_type == SearchType.MD:
349-
self._run_md_search(dblp_feed=dblp_feed)
350+
try:
351+
if self.search_source.search_type == SearchType.MD:
352+
self._run_md_search(dblp_feed=dblp_feed)
350353

351-
elif self.search_source.search_type in [
352-
SearchType.API,
353-
SearchType.TOC,
354-
]:
355-
self._run_api_search(dblp_feed=dblp_feed, rerun=rerun)
354+
elif self.search_source.search_type in [
355+
SearchType.API,
356+
SearchType.TOC,
357+
]:
358+
self._run_api_search(dblp_feed=dblp_feed, rerun=rerun)
356359

357-
else:
358-
raise NotImplementedError
360+
else:
361+
raise NotImplementedError
362+
except requests.exceptions.ConnectTimeout:
363+
self.logger.warning(
364+
f"{Colors.RED}Skipping DBLP search (API currently not available){Colors.END}"
365+
)
359366

360367
def load(self) -> dict:
361368
"""Load the records from the SearchSource file"""

0 commit comments

Comments
 (0)