Exemple #1
0
def _execute_next(result, result_index, event, session, statements, results,
                  future, num_finished, to_execute, first_error):
    if result is not _sentinel:
        if future.has_more_pages:
            result = PagedResult(future, result)
            future.clear_callbacks()
        results[result_index] = (True, result)
        finished = next(num_finished)
        if finished >= to_execute:
            event.set()
            return

    try:
        (next_index, (statement, params)) = next(statements)
    except StopIteration:
        return

    try:
        future = session.execute_async(statement, params)
        args = (next_index, event, session, statements, results, future,
                num_finished, to_execute, first_error)
        future.add_callbacks(callback=_execute_next,
                             callback_args=args,
                             errback=_handle_error,
                             errback_args=args)
    except Exception as exc:
        if first_error is not None:
            if six.PY2:
                first_error.append(sys.exc_info())
            else:
                first_error.append(exc)
            event.set()
            return
        else:
            results[next_index] = (False, exc)
            if next(num_finished) >= to_execute:
                event.set()
                return
Exemple #2
0
 def _on_success(self, result, future, idx):
     if future.has_more_pages:
         result = PagedResult(future, result)
         future.clear_callbacks()
     self._put_result(result, idx, True)