Broken timeout #2658
Answered
by
tomchristie
karpetrosyan
asked this question in
Potential Issue
Broken timeout
#2658
-
timeout argument doesn't work server.py import asyncio
from fastapi import FastAPI
app = FastAPI()
@app.get("/slow_response")
async def slow_request():
await asyncio.sleep(10) test.py @pytest.mark.anyio
async def test_timeout_exception(app):
async with httpx.AsyncClient(app=app, base_url="https://example.com", timeout=1) as client:
await client.get("/slow_response", timeout=1) $ time pytest tests/test_downloader.py::test_timeout_exception
. [100%]
1 passed in 10.11s
pytest tests/test_downloader.py::test_timeout_exception -q 0.58s user 0.07s system 6% cpu 10.665 total How this works? The request takes 10 seconds but it works fine with 1 second timeout |
Beta Was this translation helpful? Give feedback.
Answered by
tomchristie
Apr 13, 2023
Replies: 1 comment 2 replies
-
Timeouts aren't currently supported when interacting with an ASGI or WSGI app. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
karpetrosyan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Timeouts aren't currently supported when interacting with an ASGI or WSGI app.
They're only applied if you're making actual network requests.
We should probably start by documenting this, we could then follow up by determining if we want to change that behaviour or not.