Skip to content

Commit d93f1bd

Browse files
committed
Add passthrough for max_retries in get_xml
1 parent 4cf4f0b commit d93f1bd

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

indra/literature/pmc_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def _run_pmc_xml_request(pmc_params: dict, max_retries: int = 4):
367367
return res
368368

369369

370-
def get_xml(pmc_id: str, raise_for_status: bool = False):
370+
def get_xml(pmc_id: str, raise_for_status: bool = False, max_retries: int = 4):
371371
"""Returns XML for the article corresponding to a PMC ID
372372
373373
Parameters
@@ -377,6 +377,9 @@ def get_xml(pmc_id: str, raise_for_status: bool = False):
377377
raise_for_status :
378378
If True, raise an HTTPError if the request fails. If False, return
379379
None on failure.
380+
max_retries :
381+
Maximum number of retries to make if the request fails with a 429
382+
error.
380383
381384
Returns
382385
-------
@@ -410,7 +413,7 @@ def get_xml(pmc_id: str, raise_for_status: bool = False):
410413
params['identifier'] = 'oai:pubmedcentral.nih.gov:%s' % pmc_id
411414
params['metadataPrefix'] = 'pmc'
412415
# Submit the request
413-
res = _run_pmc_xml_request(params)
416+
res = _run_pmc_xml_request(params, max_retries=max_retries)
414417
if raise_for_status:
415418
res.raise_for_status()
416419
if not res.status_code == 200:

0 commit comments

Comments
 (0)