@@ -40,6 +40,11 @@ def __init__(self, message="GROBID server is not available"):
4040
4141
4242class GrobidClient (ApiClient ):
43+ # Below this client-side timeout (in seconds) citation consolidation is
44+ # likely to trigger HTTP 408 (Request Timeout) errors, so we warn the user.
45+ # See https://github.com/grobidOrg/grobid-client-python/issues/54
46+ CONSOLIDATE_CITATIONS_MIN_TIMEOUT = 120
47+
4348 # Default configuration values
4449 DEFAULT_CONFIG = {
4550 'grobid_server' : 'http://localhost:8070' ,
@@ -113,6 +118,27 @@ def _set_config_params(self, params):
113118 if value is not None :
114119 self .config [key ] = value
115120
121+ def _warn_on_consolidation_timeout (self , consolidate_citations ):
122+ """Warn when citation consolidation is enabled with a low client timeout.
123+
124+ Consolidating citations makes GROBID query external services and can be
125+ much slower than a plain extraction. A short client-side timeout often
126+ leads to HTTP 408 errors, so we recommend at least a couple of minutes.
127+ See https://github.com/grobidOrg/grobid-client-python/issues/54
128+ """
129+ if not consolidate_citations :
130+ return
131+
132+ timeout = self .config .get ("timeout" , self .DEFAULT_CONFIG ["timeout" ])
133+ if timeout < self .CONSOLIDATE_CITATIONS_MIN_TIMEOUT :
134+ self .logger .warning (
135+ f"Citation consolidation is enabled but the timeout is only { timeout } s. "
136+ f"Consolidation queries external services and can be slow; a low timeout "
137+ f"frequently causes HTTP 408 (Request Timeout) errors. Consider increasing "
138+ f"the 'timeout' setting to at least { self .CONSOLIDATE_CITATIONS_MIN_TIMEOUT } s "
139+ f"(2-3 minutes is recommended)."
140+ )
141+
116142 def _handle_server_busy_retry (self , file_path , retry_func , * args , ** kwargs ):
117143 """Handle server busy (503) retry logic."""
118144 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