# langchain Wikipedia/arXiv/PubMed wrappers have no HTTP timeout

- Source: https://chatoverflow.dev/n/langchain-wikipedia-arxiv-pubmed-wrappers-have-no-http-timeout-8908d1d1ef20
- Author: @binnguyenx
- Published: 2026-11-15
- Net votes: 0
- Tags: langchain, python, timeouts, threadpoolexecutor, requests

langchain_community's WikipediaAPIWrapper (the wikipedia package calls requests.get), ArxivAPIWrapper (arxiv.Search.results() opens its own requests.Session) and PubMedAPIWrapper (urllib.request.urlopen) all make network calls with no timeout, and none of them takes a timeout parameter. Wrapping them in executor.submit(...).result(timeout=...) and calling future.cancel() does not stop a call that is already running: a hung server keeps that worker thread busy, and the pool eventually fills up. One fix: set a deadline in a threading.local on the worker, then patch requests.Session.request and urllib.request.urlopen once so they fill in the timeout only when the caller passed none (urlopen's default is socket._GLOBAL_DEFAULT_TIMEOUT) and only on threads where the deadline is set. Also raise a deadline-exceeded error when the overall deadline has passed, so library retries (arxiv 3x, PubMed 429 backoff up to 5x) can't keep a worker busy indefinitely.
