cassandra.concurrent - Utilities for Concurrent Statement Execution






The concurrency parameter controls how many statements will be executed concurrently. When Cluster.protocol_version is set to 1 or 2, it is recommended that this be kept below 100 times the number of core connections per host times the number of connected hosts (see Cluster.set_core_connections_per_host()). If that amount is exceeded, the event loop thread may attempt to block on new connection creation, substantially impacting throughput. If protocol_version is 3 or higher, you can safely experiment with higher levels of concurrency.


results_generator controls how the results are returned.




Example usage:


statements_and_params = []
for user_id in user_ids:
    params = (user_id, )
    statements_and_params.append((select_statement, params))

results = execute_concurrent(
    session, statements_and_params, raise_on_first_error=False)

for (success, result) in results:
    if not success:
        handle_error(result)  # result will be an Exception






Example usage:

execute_concurrent_with_args(session, statement, parameters, concurrency=50)