MCPcopy
hub / github.com/redis/redis-py / _execute

Method _execute

redis/asyncio/cluster.py:2613–2752  ·  view source on GitHub ↗
(
        self,
        client: "RedisCluster",
        stack: List["PipelineCommand"],
        raise_on_error: bool = True,
        allow_redirections: bool = True,
    )

Source from the content-addressed store, hash-verified

2611 await self.reset()
2612
2613 async def _execute(
2614 self,
2615 client: "RedisCluster",
2616 stack: List["PipelineCommand"],
2617 raise_on_error: bool = True,
2618 allow_redirections: bool = True,
2619 ) -> List[Any]:
2620 todo = [
2621 cmd for cmd in stack if not cmd.result or isinstance(cmd.result, Exception)
2622 ]
2623
2624 nodes = {}
2625 for cmd in todo:
2626 passed_targets = cmd.kwargs.pop("target_nodes", None)
2627 command_policies = await client._policy_resolver.resolve(
2628 cmd.args[0].lower()
2629 )
2630
2631 if passed_targets and not client._is_node_flag(passed_targets):
2632 target_nodes = client._parse_target_nodes(passed_targets)
2633
2634 if not command_policies:
2635 command_policies = CommandPolicies()
2636 else:
2637 if not command_policies:
2638 command_flag = client.command_flags.get(cmd.args[0])
2639 if not command_flag:
2640 # Fallback to default policy
2641 if not client.get_default_node():
2642 slot = None
2643 else:
2644 slot = await client._determine_slot(*cmd.args)
2645 if slot is None:
2646 command_policies = CommandPolicies()
2647 else:
2648 command_policies = CommandPolicies(
2649 request_policy=RequestPolicy.DEFAULT_KEYED,
2650 response_policy=ResponsePolicy.DEFAULT_KEYED,
2651 )
2652 else:
2653 if command_flag in client._command_flags_mapping:
2654 command_policies = CommandPolicies(
2655 request_policy=client._command_flags_mapping[
2656 command_flag
2657 ]
2658 )
2659 else:
2660 command_policies = CommandPolicies()
2661
2662 target_nodes = await client._determine_nodes(
2663 *cmd.args,
2664 request_policy=command_policies.request_policy,
2665 node_flag=passed_targets,
2666 )
2667 if not target_nodes:
2668 raise RedisClusterException(
2669 f"No targets were found to execute {cmd.args} command on"
2670 )

Callers 1

executeMethod · 0.95

Calls 15

CommandPoliciesClass · 0.90
truncate_textFunction · 0.90
_is_node_flagMethod · 0.80
_determine_slotMethod · 0.80
monotonicMethod · 0.80
replace_default_nodeMethod · 0.80
resolveMethod · 0.45
_parse_target_nodesMethod · 0.45
getMethod · 0.45
get_default_nodeMethod · 0.45

Tested by

no test coverage detected