Closed
Description
Crash report
What happened?
Love eager task factory, but it's crashing one of my tests. I'm using uvicorn
and fastapi
to host an API, and testing it with httpx
running in the same event loop. This reliably produces a segfault.
It seems to only happen with streaming responses.
Here's a minimal code example:
import asyncio
import httpx
import uvicorn
from fastapi import FastAPI
from starlette.responses import StreamingResponse
async def main():
loop = asyncio.get_running_loop()
loop.set_task_factory(asyncio.eager_task_factory)
app = FastAPI()
@app.get("/")
async def get():
async def _():
yield "1"
return StreamingResponse(
_(),
)
server = uvicorn.Server(
uvicorn.Config(
app,
host="0.0.0.0",
port=8080,
)
)
asyncio.create_task(server.serve())
client = httpx.AsyncClient()
await client.get("http://localhost:8080")
if __name__ == "__main__":
asyncio.run(main())
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Output from running 'python -VV' on the command line:
Python 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:35:20) [Clang 16.0.6 ]
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done