title: Cassandra python driver execute_async with callback not working as expected
body: <p>I am trying to query data from Cassandra using the datastax python driver. I would like this query to be as fast as possible. I was using the synchronous <code>session.execute</code> method but would like to use the asynchronous <code>session.execute_async</code> as it will presumably be more efficient by not having to wait for the row processing code to complete. </p>
  
  <p>When I try to use this approach, as per the documentation it does not work. I am on Ubuntu 14.0.4 using Cassandra 2.1.3 and the v2.5 cassandra python driver.</p>
  
  <p>The following code is enough to reproduce the issue on my machine:</p>
  
  <pre><code>def print_row_count(rows, label):
      for i, row in enumerate(rows):
          do_something = row
      print "{}: processed {} rows".format(label, i+1)
  
  def print_err(reason):
      print "Error: {}".format(reason)
  
  cluster = Cluster(['192.168.1.100'])
  session = cluster.connect()
  session.set_keyspace("foo")
  session.default_fetch_size = 200
  future_res = session.execute_async("SELECT * FROM bar LIMIT 1000;")
  future_res.add_callback(print_row_count, 'Async')
  future_res.add_errback(print_err)
  </code></pre>
  
  <p>When I execute this code nothing gets printed.</p>
  
  <p>However when I add into the blocking call to <code>ResponseFuture.result</code> that synchronous call gets executed as well as the original async calls.</p>
  
  <pre><code>block_future_res = future_res.result()
  print_row_count(block_future_res, 'BlockFuture') 
  </code></pre>
  
  <p>Output after running with these two lines added:</p>
  
  <pre><code>Async: processed 200 rows
  Async: processed 200 rows
  Async: processed 200 rows
  Async: processed 200 rows
  Async: processed 200 rows
  BlockFuture: processed 1000 rows
  </code></pre>
  
  <p>Perhaps I misunderstand how the callback system works but I can't see anywhere in the <a href="http://datastax.github.io/python-driver/api/cassandra/cluster.html#cassandra.cluster.ResponseFuture.add_callback" rel="nofollow">docs</a> where you need to call <code>result()</code> first for the callbacks to execute. </p>
  
  <p>Any help appreciated.</p>
  
  <p>Update:</p>
  
  <p>The initial question about callback behaviour is answered by @WangST
  However I wanted to be able to page through async_executions and the following code allows this:</p>
  
  <pre><code>future = session.execute_async("SELECT * FROM metadata LIMIT 1000;")
  future.add_callback(print_row_count, 'Async')
  future.add_errback(print_err)
  
  # Call this once so that the future has_more_pages value is set
  future_res = future.result()
  while future.has_more_pages:
      future.start_fetching_next_page()
      future_res = future.result()
  </code></pre>