Execute the graph query and return a :class:`ResponseFuture` object which callbacks may be attached to for asynchronous response delivery. You may also call ``ResponseFuture.result()`` to synchronously block for results at any time.
(self, query, parameters=None, trace=False, execution_profile=EXEC_PROFILE_GRAPH_DEFAULT, execute_as=None)
| 2797 | return self.execute_graph_async(query, parameters, trace, execution_profile, execute_as).result() |
| 2798 | |
| 2799 | def execute_graph_async(self, query, parameters=None, trace=False, execution_profile=EXEC_PROFILE_GRAPH_DEFAULT, execute_as=None): |
| 2800 | """ |
| 2801 | Execute the graph query and return a :class:`ResponseFuture` |
| 2802 | object which callbacks may be attached to for asynchronous response delivery. You may also call ``ResponseFuture.result()`` to synchronously block for |
| 2803 | results at any time. |
| 2804 | """ |
| 2805 | if self.cluster._config_mode is _ConfigMode.LEGACY: |
| 2806 | raise ValueError(("Cannot execute graph queries using Cluster legacy parameters. " |
| 2807 | "Consider using Execution profiles: " |
| 2808 | "https://docs.datastax.com/en/developer/python-driver/latest/execution_profiles/#execution-profiles")) |
| 2809 | |
| 2810 | if not isinstance(query, GraphStatement): |
| 2811 | query = SimpleGraphStatement(query) |
| 2812 | |
| 2813 | # Clone and look up instance here so we can resolve and apply the extended attributes |
| 2814 | execution_profile = self.execution_profile_clone_update(execution_profile) |
| 2815 | |
| 2816 | if not hasattr(execution_profile, 'graph_options'): |
| 2817 | raise ValueError( |
| 2818 | "Execution profile for graph queries must derive from GraphExecutionProfile, and provide graph_options") |
| 2819 | |
| 2820 | self._resolve_execution_profile_options(execution_profile) |
| 2821 | |
| 2822 | # make sure the graphson context row factory is binded to this cluster |
| 2823 | try: |
| 2824 | if issubclass(execution_profile.row_factory, _GraphSONContextRowFactory): |
| 2825 | execution_profile.row_factory = execution_profile.row_factory(self.cluster) |
| 2826 | except TypeError: |
| 2827 | # issubclass might fail if arg1 is an instance |
| 2828 | pass |
| 2829 | |
| 2830 | # set graph paging if needed |
| 2831 | self._maybe_set_graph_paging(execution_profile) |
| 2832 | |
| 2833 | graph_parameters = None |
| 2834 | if parameters: |
| 2835 | graph_parameters = self._transform_params(parameters, graph_options=execution_profile.graph_options) |
| 2836 | |
| 2837 | custom_payload = execution_profile.graph_options.get_options_map() |
| 2838 | if execute_as: |
| 2839 | custom_payload[_proxy_execute_key] = execute_as.encode() |
| 2840 | custom_payload[_request_timeout_key] = int64_pack(int(execution_profile.request_timeout * 1000)) |
| 2841 | |
| 2842 | future = self._create_response_future(query, parameters=None, trace=trace, custom_payload=custom_payload, |
| 2843 | timeout=_NOT_SET, execution_profile=execution_profile) |
| 2844 | |
| 2845 | future.message.query_params = graph_parameters |
| 2846 | future._protocol_handler = self.client_protocol_handler |
| 2847 | |
| 2848 | if execution_profile.graph_options.is_analytics_source and \ |
| 2849 | isinstance(execution_profile.load_balancing_policy, DefaultLoadBalancingPolicy): |
| 2850 | self._target_analytics_master(future) |
| 2851 | else: |
| 2852 | future.send_request() |
| 2853 | return future |
| 2854 | |
| 2855 | def _maybe_set_graph_paging(self, execution_profile): |
| 2856 | graph_paging = execution_profile.continuous_paging_options |