MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / execute_async

Method execute_async

cassandra/cluster.py:2644–2691  ·  view source on GitHub ↗

Execute the given query and return a :class:`~.ResponseFuture` object which callbacks may be attached to for asynchronous response delivery. You may also call :meth:`~.ResponseFuture.result()` on the :class:`.ResponseFuture` to synchronously block for results at

(self, query, parameters=None, trace=False, custom_payload=None,
                      timeout=_NOT_SET, execution_profile=EXEC_PROFILE_DEFAULT,
                      paging_state=None, host=None, execute_as=None)

Source from the content-addressed store, hash-verified

2642 return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state, host, execute_as).result()
2643
2644 def execute_async(self, query, parameters=None, trace=False, custom_payload=None,
2645 timeout=_NOT_SET, execution_profile=EXEC_PROFILE_DEFAULT,
2646 paging_state=None, host=None, execute_as=None):
2647 """
2648 Execute the given query and return a :class:`~.ResponseFuture` object
2649 which callbacks may be attached to for asynchronous response
2650 delivery. You may also call :meth:`~.ResponseFuture.result()`
2651 on the :class:`.ResponseFuture` to synchronously block for results at
2652 any time.
2653
2654 See :meth:`Session.execute` for parameter definitions.
2655
2656 Example usage::
2657
2658 >>> session = cluster.connect()
2659 >>> future = session.execute_async("SELECT * FROM mycf")
2660
2661 >>> def log_results(results):
2662 ... for row in results:
2663 ... log.info("Results: %s", row)
2664
2665 >>> def log_error(exc):
2666 >>> log.error("Operation failed: %s", exc)
2667
2668 >>> future.add_callbacks(log_results, log_error)
2669
2670 Async execution with blocking wait for results::
2671
2672 >>> future = session.execute_async("SELECT * FROM mycf")
2673 >>> # do other stuff...
2674
2675 >>> try:
2676 ... results = future.result()
2677 ... except Exception:
2678 ... log.exception("Operation failed:")
2679
2680 """
2681 custom_payload = custom_payload if custom_payload else {}
2682 if execute_as:
2683 custom_payload[_proxy_execute_key] = execute_as.encode()
2684
2685 future = self._create_response_future(
2686 query, parameters, trace, custom_payload, timeout,
2687 execution_profile, paging_state, host)
2688 future._protocol_handler = self.client_protocol_handler
2689 self._on_request(future)
2690 future.send_request()
2691 return future
2692
2693 def execute_concurrent(self, statements_and_parameters, concurrency=100, raise_on_first_error=True, results_generator=False, execution_profile=EXEC_PROFILE_DEFAULT):
2694 """

Calls 4

_on_requestMethod · 0.95
send_requestMethod · 0.80
encodeMethod · 0.45