Skip to content

Commit c850fa9

Browse files
bbrowning918carltongibson
authored andcommitted
add test for async_to_sync
1 parent 313e278 commit c850fa9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,20 @@ async def test_group_send_capacity_multiple_channels(channel_layer, caplog):
401401
)
402402

403403

404+
def test_repeated_group_send_with_async_to_sync(channel_layer):
405+
"""
406+
Makes sure repeated group_send calls wrapped in async_to_sync
407+
process-local channel names.
408+
"""
409+
channel_layer = RedisChannelLayer(hosts=TEST_HOSTS, capacity=3)
410+
411+
try:
412+
async_to_sync(channel_layer.group_send)('channel_name_1', {"type": "test.message.1"})
413+
async_to_sync(channel_layer.group_send)('channel_name_2', {"type": "test.message.2"})
414+
except RuntimeError as exc:
415+
pytest.fail(F"repeated async_to_sync wrapped group_send calls raised {exc}")
416+
417+
404418
@pytest.mark.asyncio
405419
async def test_receive_cancel(channel_layer):
406420
"""

0 commit comments

Comments
 (0)