title: How to resolve "cassandra.cluster.NoHostAvailable" in a Python multi threaded program
body: <p>I am trying to insert records into Cassandra using a multi threaded Python program. I am running this program simultaneously on 3 machines. For some time being records are getting inserted, but later I am getting below exception. I am using driver provided by datastax.</p>
  
  <blockquote>
    <p>cassandra.cluster.NoHostAvailable</p>
  </blockquote>
  
  <p>I did some search and found out (source: <a href="https://datastax.github.io/python-driver/api/cassandra/cluster.html">https://datastax.github.io/python-driver/api/cassandra/cluster.html</a>)</p>
  
  <blockquote>
    <p>exception cassandra.cluster.NoHostAvailable <br>
    Raised when an operation
    is attempted but all connections are busy, defunct, closed, or
    resulted in errors when used.</p>
  </blockquote>
  
  <p>My question is: <br>
  1. Is this a normal exception one could face with too many connection to Cassandra. <br>
  2. How would I resolve this in a situation where I want to create many connection/session to/of cassandra. (I know creating too many session is not advisable, it impact server performance as each session consume a handful amount of memory)</p>
  
  <p>Below is the code fragment.</p>
  
  <pre><code>cluster = Cluster(['192.168.1.21'])
  session = cluster.connect('myNameSpace')
  
  def insertInToCassandra(catRange):
      for x in catRange:
          //function to insert records into Cassandra table
  
  ProductRange = [
      range(900,920),
      range(921,940),
      range(941,960),
      range(961,980),
      range(981,1000)
       ]
  
  # Make the Pool of workers
  pool = ThreadPool(20)
  
  # Open the urls in their own threads
  # and return the results
  results = pool.map(insertInToCassandra, ProductRange)
  
  #close the pool and wait for the work to finish
  pool.close()
  pool.join()
  </code></pre>