Closed Buuntu closed 7 months ago
@Buuntu I too have got the same issue on testing ./scripts/test
for redis. on examining with redis-cli monitor
command inside redis, it is seen that publishing to the channel happens before subscribe and it is waiting forever to get published data.The test examined is
@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. Feel free to reopen.
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 https://github.com/encode/broadcaster/pull/2#issuecomment-591407905 and https://github.com/encode/broadcaster/issues/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?