Skip to content

Commit 6a5da1d

Browse files
authored
Adding variable timeouts for clients (#1015)
1 parent a335505 commit 6a5da1d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

paperqa/clients/crossref.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838

3939
CROSSREF_HOST = "api.crossref.org"
4040
CROSSREF_BASE_URL = f"https://{CROSSREF_HOST}"
41-
CROSSREF_API_REQUEST_TIMEOUT = 5.0
41+
CROSSREF_API_REQUEST_TIMEOUT = float(
42+
os.environ.get("CROSSREF_API_REQUEST_TIMEOUT", "10.0")
43+
) # seconds
4244
CROSSREF_API_MAPPING: dict[str, Collection[str]] = {
4345
"title": {"title"},
4446
"doi": {"DOI"},

paperqa/clients/openalex.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
from .exceptions import DOINotFoundError
1818

1919
OPENALEX_BASE_URL = "https://api.openalex.org"
20-
OPENALEX_API_REQUEST_TIMEOUT = 5.0
20+
OPENALEX_API_REQUEST_TIMEOUT = float(
21+
os.environ.get("OPENALEX_API_REQUEST_TIMEOUT", "10.0")
22+
) # seconds
2123

2224
logger = logging.getLogger(__name__)
2325

paperqa/clients/semantic_scholar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
"citation_count": {"citationCount"},
4646
"source_quality": {"journal"},
4747
}
48-
SEMANTIC_SCHOLAR_API_REQUEST_TIMEOUT = 10.0
48+
SEMANTIC_SCHOLAR_API_REQUEST_TIMEOUT = float(
49+
os.environ.get("SEMANTIC_SCHOLAR_API_REQUEST_TIMEOUT", "10.0")
50+
) # seconds
4951
SEMANTIC_SCHOLAR_API_FIELDS: str = ",".join(
5052
union_collections_to_ordered_list(SEMANTIC_SCHOLAR_API_MAPPING.values())
5153
)

0 commit comments

Comments
 (0)