Thang Kieu
12/10/2025, 7:19 AM06:51:10.060 | DEBUG | prefect.client - Encountered retryable exception during request. Another attempt will be made in 2.1943795936861705s. This is attempt 1/6.
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 394, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 232, in handle_async_request
connection = await pool_request.wait_for_connection(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 35, in wait_for_connection
await self._connection_acquired.wait(timeout=timeout)
File "/usr/local/lib/python3.12/site-packages/httpcore/_synchronization.py", line 149, in wait
with map_exceptions(anyio_exc_map):
File "/usr/local/lib/python3.12/contextlib.py", line 155, in __exit__
self.gen.throw(value)
File "/usr/local/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.PoolTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/prefect/client/base.py", line 268, in _send_with_retry
response = await send(request, *send_args, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1629, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1657, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1694, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1730, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 393, in handle_async_request
with map_httpcore_exceptions():
File "/usr/local/lib/python3.12/contextlib.py", line 155, in __exit__
self.gen.throw(value)
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.PoolTimeoutMarvin
12/10/2025, 7:19 AMMarvin
12/10/2025, 7:23 AMhttpx.PoolTimeout is coming from the HTTP connection pool used by the Prefect client. In Prefect 3.x you can increase the client’s timeouts (including the pool timeout) via an environment variable, and optionally increase client retries.
What to set
- Increase all HTTPX timeouts (connect/read/write/pool) used by the Prefect client:
- PREFECT_API_REQUEST_TIMEOUT (seconds)
- Optionally increase retries for retryable errors (like PoolTimeout):
- PREFECT_CLIENT_MAX_RETRIES
- PREFECT_CLIENT_RETRY_JITTER_FACTOR (optional)
- PREFECT_CLIENT_RETRY_EXTRA_CODES (optional)
Examples
- Shell (before starting the worker):
export PREFECT_API_REQUEST_TIMEOUT=120
export PREFECT_CLIENT_MAX_RETRIES=10
prefect worker start -p <your-pool>
- Docker Compose:
services:
prefect-worker:
image: prefecthq/prefect:3-latest
command: prefect worker start -p your-pool
environment:
PREFECT_API_URL: <https://api.prefect.cloud/api/accounts/<acct>/workspaces/<ws>>
PREFECT_API_KEY: <your-key>
PREFECT_API_REQUEST_TIMEOUT: "120"
PREFECT_CLIENT_MAX_RETRIES: "10"
- Kubernetes (snippet):
env:
- name: PREFECT_API_REQUEST_TIMEOUT
value: "120"
- name: PREFECT_CLIENT_MAX_RETRIES
value: "10"
Notes
- Workers use the standard Prefect client under the hood, so they’ll pick these up from the environment automatically; there isn’t a dedicated CLI flag just for the pool timeout.
- If you continue to see pool timeouts, you may be saturating connections (e.g., due to proxy/network constraints). Prefect’s client also limits concurrent connections by default for stability; this isn’t currently adjustable via environment variables. If you need to tune HTTPX limits at a low level, that requires creating a custom client with httpx_settings in code, which the CLI worker does not expose.
If you can share a bit more about your setup (Prefect Cloud vs self-hosted API, where the worker runs, presence of proxies), I can suggest more targeted tweaks.Thang Kieu
12/10/2025, 7:27 AMMarvin
12/10/2025, 7:27 AMMarvin
12/10/2025, 7:28 AMAPISettings.request_timeout) and maps to the env var PREFECT_API_REQUEST_TIMEOUT.
- Programmatic check:
from prefect.settings import PREFECT_API_REQUEST_TIMEOUT
PREFECT_API_REQUEST_TIMEOUT.value() # -> 60.0