Test hangs forever when using AsyncClient.stream() on a SSE endpoint #1787
Unanswered
havardthom
asked this question in
Potential Issue
Replies: 2 comments 1 reply
-
Similar to fastapi/fastapi#2006 I got my test working with https://pypi.org/project/async-asgi-testclient/ So I believe there is some issue with AsyncClient.stream() which causes the test to hang forever. Working pseudo test:
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Wondering if this will be fixed by #998? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have an SSE endpoint created with FastAPI + sse-starlette + aioredis. The SSE endpoint is subscribed to a redis channel and returns an event source response to the connected client whenever a message is published to the channel.
I'm trying to test this SSE endpoint using HTTPX AsyncClient but the test hangs forever when I try to run it. I suspect it is because the test code and the server code is running on the same asyncio loop and the thread is blocked by the SSE endpoint code waiting for a message from redis. Has anyone run into this problem before, is there a smart way to run the test code in a separate thread from the server code so it is not blocked by a running SSE loop?
Some pseudo code for my test to show what im trying
(Also found a similar issue which could be related: fastapi/fastapi#2006)
Beta Was this translation helpful? Give feedback.
All reactions