-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test hangs with Redis backend in Starlette/FastAPI #44
Comments
@Buuntu I too have got the same issue on testing @pytest.mark.asyncio
async def test_redis():
async with Broadcast("redis://localhost:6379") as broadcast:
async with broadcast.subscribe("chatroom") as subscriber:
await broadcast.publish("chatroom", "hello")
event = await subscriber.get()
assert event.channel == "chatroom"
assert event.message == "hello" Redis cli output But it was working after adding a minimal delay before publish import asyncio
@pytest.mark.asyncio
async def test_redis():
async with Broadcast("redis://localhost:6379") as broadcast:
async with broadcast.subscribe("chatroom") as subscriber:
await asyncio.sleep(0.01)
await broadcast.publish("chatroom", "hello")
event = await subscriber.get()
assert event.channel == "chatroom"
assert event.message == "hello" Redis cli output In this case subscribe occur before publish and the test got passed. (looks like a Heisunbug) |
We changed the underlying Redis library to redis-py. Can you please re-test if the issue is still there? |
It does not hang either in tests nor in the example. I think this issue is fixed. |
Closing it as stalled. Feel free to reopen. |
Using the testing example from the Starlette docs with a route that uses a Redis websocket just hangs indefinitely:
this however, works fine:
maybe it's related to this #2 (comment) and #42?
I think it's the same with a memory backend. Has anyone successfully tested a Starlette websocket route?
UPDATE: I tried running
./scripts/test
locally from the broadcaster directory and it actually hangs for me on the redis test. Anyone else getting that?The text was updated successfully, but these errors were encountered: