Skip to content

Commit

Permalink
Add regression test for django#332
Browse files Browse the repository at this point in the history
  • Loading branch information
sevdog committed Apr 3, 2023
1 parent 8b4ed2d commit 78784e6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,21 @@ def test_deserialize():

assert isinstance(deserialized, dict)
assert deserialized == {"a": True, "b": None, "c": {"d": []}}


def test_close_connection_pools_on_loop_close(channel_layer):
"""
Regression test for
https://github.com/django/channels_redis/issues/332
"""
channel_layer = RedisChannelLayer(hosts=TEST_HOSTS)

async def send(channel, message):
await channel_layer.send(channel, message)

channel_name_1 = async_to_sync(channel_layer.new_channel)()
# send message in a different threadf
async_to_sync(send)(channel_name_1, {"type": "test.message.1"})
# close from an other thread
async_to_sync(channel_layer.close_pools)()
18 changes: 18 additions & 0 deletions tests/test_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,3 +701,21 @@ def test_deserialize():

assert isinstance(deserialized, dict)
assert deserialized == {"a": True, "b": None, "c": {"d": []}}


def test_close_connection_pools_on_loop_close(channel_layer):
"""
Regression test for
https://github.com/django/channels_redis/issues/332
"""
channel_layer = RedisChannelLayer(hosts=TEST_HOSTS)

async def send(channel, message):
await channel_layer.send(channel, message)

channel_name_1 = async_to_sync(channel_layer.new_channel)()
# send message in a different threadf
async_to_sync(send)(channel_name_1, {"type": "test.message.1"})
# close from an other thread
async_to_sync(channel_layer.close_pools)()

0 comments on commit 78784e6

Please sign in to comment.