title: pymongo.errors.CursorNotFound: cursor id '...' not valid at server
body: <p>I am trying to fetch some ids that exist in a mongo database with the following code:</p>
  
  <pre><code>client = MongoClient('xx.xx.xx.xx', xxx)
  db = client.test_database
  db = client['...']
  collection = db.test_collection
  collection = db["..."]
  
  
  for cursor in collection.find({ "$and" : [{ "followers" : { "$gt" : 2000 } }, { "followers" : { "$lt" : 3000 } }, { "list_followers" : { "$exists" : False } }] }): 
      print cursor['screenname']
      print cursor['_id']['uid']
      id = cursor['_id']['uid']
  </code></pre>
  
  <p>However, after a short while, I am receive this error: </p>
  
  <blockquote>
    <p>pymongo.errors.CursorNotFound: cursor id '...' not valid at server.</p>
  </blockquote>
  
  <p>I found this <a href="https://stackoverflow.com/questions/10298354/mongodb-cursor-id-not-valid-error">article</a> which refers to that problem. Nevertheless it is not clear to me which solution to take.  Is it possible to use <code>find().batch_size(30)</code>? What exactly does the above command do? Can I take all the database ids using <code>batch_size</code>?</p>