diff --git a/examples/python/client_example.py b/examples/python/client_example.py index 7620348a5b..9e907447d7 100755 --- a/examples/python/client_example.py +++ b/examples/python/client_example.py @@ -13,7 +13,6 @@ RedisClusterClient, ) - def set_console_logger(level: LogLevel = LogLevel.WARN): Logger.set_logger_config(level) @@ -42,7 +41,7 @@ async def test_standalone_client(host: str = "localhost", port: int = 6379): # Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options. config = BaseClientConfiguration( addresses=addresses, - client_name="test_standalone_client" + client_name="test_standalone_client", # if the server use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently. # use_tls=True ) @@ -52,16 +51,17 @@ async def test_standalone_client(host: str = "localhost", port: int = 6379): await send_set_and_get(client) # Send PING to the primary node pong = await client.custom_command(["PING"]) - print(f"PONG response is = {pong}") + assert isinstance(pong, bytes) + print(f"PONG response is = {pong.decode()}") -async def test_cluster_client(host: str = "localhost", port: int = 6379): +async def test_cluster_client(host: str = "localhost", port: int = 45027): # When in Redis is cluster mode, add address of any nodes, and the client will find all nodes in the cluster. addresses = [NodeAddress(host, port)] # Check `RedisClientConfiguration/ClusterClientConfiguration` for additional options. config = BaseClientConfiguration( addresses=addresses, - client_name="test_cluster_client" + client_name="test_cluster_client", # if the cluster nodes use TLS, you'll need to enable it. Otherwise the connection attempt will time out silently. # use_tls=True ) @@ -71,10 +71,11 @@ async def test_cluster_client(host: str = "localhost", port: int = 6379): await send_set_and_get(client) # Send PING to all primaries (according to Redis's PING request_policy) pong = await client.custom_command(["PING"]) - print(f"PONG response is = {pong}") + assert isinstance(pong, bytes) + print(f"PONG response is = {pong.decode()}") # Send INFO REPLICATION with routing option to all nodes info_repl_resps = await client.custom_command(["INFO", "REPLICATION"], AllNodes()) - print(f"INFO REPLICATION responses to all nodes are = {info_repl_resps}") + print(f"INFO REPLICATION responses to all nodes are = {info_repl_resps!r}") async def main(): diff --git a/python/src/lib.rs b/python/src/lib.rs index f77624d168..fd2a25aa79 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -114,13 +114,6 @@ fn glide(_py: Python, m: &PyModule) -> PyResult<()> { Value::Okay => Ok("OK".into_py(py)), Value::Int(num) => Ok(num.into_py(py)), Value::BulkString(data) => { - // TODO: for now, and in order to keep the current tests to work, - // we still return a UTF-8 encoded string instead of `&[u8]`. This needs - // to be changed - - // let value_str = String::from_utf8_lossy(&data); - // Ok(value_str.into_py(py)) - let data_bytes = PyBytes::new(py, &data); Ok(data_bytes.into_py(py)) }