Skip to content

Commit 9eb4f96

Browse files
committed
Warn when consolidating citations with a low timeout
Citation consolidation makes GROBID query external services and is much slower than a plain extraction; a low client-side timeout frequently results in HTTP 408 (Request Timeout) errors. Emit a warning when consolidation is enabled with a timeout below 120s and document the recommended value in the Readme. Closes #54
1 parent 2b0a245 commit 9eb4f96

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎Readme.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,14 @@ settings.
298298
> Since version 0.0.12, the config file is optional. The client will use default localhost settings if no configuration
299299
> is provided.
300300
301+
> [!WARNING]
302+
> **Citation consolidation and the `timeout` setting.** When `--consolidate_citations` (or `consolidate_citations=True`)
303+
> is enabled, GROBID queries external services (e.g. CrossRef) to enrich the extracted references. This is considerably
304+
> slower than a plain extraction, and a low `timeout` frequently causes `HTTP 408 (Request Timeout)` errors.
305+
> Set the `timeout` to at least **120 seconds (2-3 minutes recommended)** when consolidating citations. The client emits
306+
> a warning when consolidation is requested with a timeout below 120 seconds.
307+
> See [issue #54](https://github.com/grobidOrg/grobid-client-python/issues/54).
308+
301309
### Logging Configuration
302310

303311
The client provides configurable logging with different verbosity levels. By default, only essential statistics and warnings are shown.

‎grobid_client/grobid_client.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def __init__(self, message="GROBID server is not available"):
3939

4040

4141
class GrobidClient(ApiClient):
42+
# Below this client-side timeout (in seconds) citation consolidation is
43+
# likely to trigger HTTP 408 (Request Timeout) errors, so we warn the user.
44+
# See https://github.com/grobidOrg/grobid-client-python/issues/54
45+
CONSOLIDATE_CITATIONS_MIN_TIMEOUT = 120
46+
4247
# Default configuration values
4348
DEFAULT_CONFIG = {
4449
'grobid_server': 'http://localhost:8070',
@@ -112,6 +117,27 @@ def _set_config_params(self, params):
112117
if value is not None:
113118
self.config[key] = value
114119

120+
def _warn_on_consolidation_timeout(self, consolidate_citations):
121+
"""Warn when citation consolidation is enabled with a low client timeout.
122+
123+
Consolidating citations makes GROBID query external services and can be
124+
much slower than a plain extraction. A short client-side timeout often
125+
leads to HTTP 408 errors, so we recommend at least a couple of minutes.
126+
See https://github.com/grobidOrg/grobid-client-python/issues/54
127+
"""
128+
if not consolidate_citations:
129+
return
130+
131+
timeout = self.config.get("timeout", self.DEFAULT_CONFIG["timeout"])
132+
if timeout < self.CONSOLIDATE_CITATIONS_MIN_TIMEOUT:
133+
self.logger.warning(
134+
f"Citation consolidation is enabled but the timeout is only {timeout}s. "
135+
f"Consolidation queries external services and can be slow; a low timeout "
136+
f"frequently causes HTTP 408 (Request Timeout) errors. Consider increasing "
137+
f"the 'timeout' setting to at least {self.CONSOLIDATE_CITATIONS_MIN_TIMEOUT}s "
138+
f"(2-3 minutes is recommended)."
139+
)
140+
115141
def _handle_server_busy_retry(self, file_path, retry_func, *args, **kwargs):
116142
"""Handle server busy (503) retry logic."""
117143
self.logger.warning(f"Server busy (503), retrying {file_path} after {self.config['sleep_time']} seconds")
@@ -345,6 +371,13 @@ def process(
345371
start_time = time.time()
346372
batch_size_pdf = self.config["batch_size"]
347373

374+
# Warn if citation consolidation is requested with a short timeout: the
375+
# consolidation step queries external services (e.g. CrossRef) and can
376+
# be significantly slower, frequently resulting in HTTP 408 errors when
377+
# the client-side timeout is too low.
378+
# See https://github.com/grobidOrg/grobid-client-python/issues/54
379+
self._warn_on_consolidation_timeout(consolidate_citations)
380+
348381
# First pass: count all eligible files
349382
all_input_files = []
350383
for (dirpath, dirnames, filenames) in os.walk(input_path):

0 commit comments

Comments
 (0)