Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ class initializer. In the case of conflicting arguments, querystring
arguments always win.

"""
single_connection_client = kwargs.pop("single_connection_client", False)
connection_pool = ConnectionPool.from_url(url, **kwargs)
return cls(connection_pool=connection_pool)
return cls(
connection_pool=connection_pool,
single_connection_client=single_connection_client,
)

def __init__(
self,
Expand Down
6 changes: 5 additions & 1 deletion redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,12 @@ class initializer. In the case of conflicting arguments, querystring
arguments always win.

"""
single_connection_client = kwargs.pop("single_connection_client", False)
connection_pool = ConnectionPool.from_url(url, **kwargs)
return cls(connection_pool=connection_pool)
return cls(
connection_pool=connection_pool,
single_connection_client=single_connection_client,
)

def __init__(
self,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_asyncio/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,9 @@ async def open_connection(*args, **kwargs):

vals = await asyncio.gather(do_read(), do_close())
assert vals == [b"Hello, World!", None]


@pytest.mark.onlynoncluster
def test_create_single_connection_client_from_url():
client = Redis.from_url("redis://localhost:6379/0?", single_connection_client=True)
assert client.single_connection_client is True
8 changes: 8 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,11 @@ def test_pack_command(Class):

actual = Class().pack_command(*cmd)[0]
assert actual == expected, f"actual = {actual}, expected = {expected}"


@pytest.mark.onlynoncluster
def test_create_single_connection_client_from_url():
client = redis.Redis.from_url(
"redis://localhost:6379/0?", single_connection_client=True
)
assert client.connection is not None