From d5164d9f94aee148fe76d91b1956cf5ef97b3e69 Mon Sep 17 00:00:00 2001 From: Pjotr Date: Tue, 10 Nov 2026 13:19:42 +0000 Subject: genes: give the Wikidata call 30 s, not 20 Two SPARQL queries in a row, and Wikidata's query service measured 9 s for one of them during the deploy -- so the first call for a symbol timed out at 20 s and answered 502 while the service was merely slow. Only the first call pays it; the answer is cached for a week. The refusal now says how long it waited. --- src/wikidata.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wikidata.rs b/src/wikidata.rs index 2a69ddb..f5f75a2 100644 --- a/src/wikidata.rs +++ b/src/wikidata.rs @@ -226,10 +226,16 @@ fn fetch( }) } +/// How long one SPARQL call may take. Wikidata's query service answers in +/// one to three seconds usually, but is a shared public service and has been +/// measured at nine; two queries in a row need the room, and only the first +/// call for a symbol pays it (the answer is cached for a week). +const SPARQL_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30); + /// `POST query=…` to a SPARQL endpoint, asking for SPARQL JSON. fn sparql(endpoint: &str, query: &str) -> Result { let agent = ureq::Agent::config_builder() - .timeout_global(Some(std::time::Duration::from_secs(20))) + .timeout_global(Some(SPARQL_TIMEOUT)) .build() .new_agent(); let response = agent @@ -237,7 +243,12 @@ fn sparql(endpoint: &str, query: &str) -> Result() -- cgit 1.4.1