diff --git a/python/python/glide/async_commands/cluster_commands.py b/python/python/glide/async_commands/cluster_commands.py index c43efd48cd..00bb1376d4 100644 --- a/python/python/glide/async_commands/cluster_commands.py +++ b/python/python/glide/async_commands/cluster_commands.py @@ -80,7 +80,7 @@ async def exec( If the transaction failed due to a WATCH command, `exec` will return `None`. """ commands = transaction.commands[:] - return await self.execute_transaction(commands, route) + return await self._execute_transaction(commands, route) async def config_resetstat( self, diff --git a/python/python/glide/async_commands/core.py b/python/python/glide/async_commands/core.py index d6d2fce8c9..a699fd475f 100644 --- a/python/python/glide/async_commands/core.py +++ b/python/python/glide/async_commands/core.py @@ -184,20 +184,19 @@ async def _execute_command( route: Optional[Route] = ..., ) -> TResult: ... - async def execute_transaction( + async def _execute_transaction( self, commands: List[Tuple[RequestType.ValueType, List[str]]], route: Optional[Route] = None, ) -> List[TResult]: ... - async def execute_script( + async def _execute_script( self, hash: str, keys: Optional[List[str]] = None, args: Optional[List[str]] = None, route: Optional[Route] = None, - ) -> TResult: - ... + ) -> TResult: ... async def set( self, @@ -1272,4 +1271,4 @@ async def invoke_script( >>> await invoke_script(lua_script, keys=["foo"], args=["bar"] ); ["foo", "bar"] """ - return await self.execute_script(script.get_hash(), keys, args) + return await self._execute_script(script.get_hash(), keys, args) diff --git a/python/python/glide/async_commands/standalone_commands.py b/python/python/glide/async_commands/standalone_commands.py index 907cd60e67..77c731e1cc 100644 --- a/python/python/glide/async_commands/standalone_commands.py +++ b/python/python/glide/async_commands/standalone_commands.py @@ -61,7 +61,7 @@ async def exec( If the transaction failed due to a WATCH command, `exec` will return `None`. """ commands = transaction.commands[:] - return await self.execute_transaction(commands) + return await self._execute_transaction(commands) async def select(self, index: int) -> TOK: """Change the currently selected Redis database. diff --git a/python/python/glide/redis_client.py b/python/python/glide/redis_client.py index da639f5835..989cb6b495 100644 --- a/python/python/glide/redis_client.py +++ b/python/python/glide/redis_client.py @@ -197,14 +197,9 @@ async def _execute_command( request.single_command.request_type = request_type request.single_command.args_array.args[:] = args # TODO - use arg pointer set_protobuf_route(request, route) - # Create a response future for this request and add it to the available - # futures map - response_future = self._get_future(request.callback_idx) - self._create_write_task(request) - await response_future - return response_future.result() + return await self._write_request_await_response(request) - async def execute_transaction( + async def _execute_transaction( self, commands: List[Tuple[RequestType.ValueType, List[str]]], route: Optional[Route] = None, @@ -223,14 +218,9 @@ async def execute_transaction( transaction_commands.append(command) request.transaction.commands.extend(transaction_commands) set_protobuf_route(request, route) - # Create a response future for this request and add it to the available - # futures map - response_future = self._get_future(request.callback_idx) - self._create_write_task(request) - await response_future - return response_future.result() + return await self._write_request_await_response(request) - async def execute_script( + async def _execute_script( self, hash: str, keys: Optional[List[str]] = None, @@ -247,6 +237,9 @@ async def execute_script( request.script_invocation.args[:] = args if args is not None else [] request.script_invocation.keys[:] = keys if keys is not None else [] set_protobuf_route(request, route) + return await self._write_request_await_response(request) + + async def _write_request_await_response(self, request: RedisRequest): # Create a response future for this request and add it to the available # futures map response_future = self._get_future(request.callback_idx)