title: How to deal with pymongo.errors.AutoReconnect: connection closed?
body: <p>I am writing a python code to update each document in collection. My code is like:</p>
  
  <pre><code>for r, d_50 in enumerate(grid50.find().batch_size(500)):
      self_grid = grid50.find({'_id':d_50['_id']})
      .....
      .....
      (processing process)
      grid50.update({'_id':d_50['_id']},{'$set':{u'big_cell8':{"POI":venue_count, "cell_ids":cell_ids}}})
  </code></pre>
  
  <p>However, when I run this code, I met problem:</p>
  
  <pre><code>   raise AutoReconnect(str(e))
     pymongo.errors.AutoReconnect: connection closed
  </code></pre>
  
  <p>Does anyone know how to deal with this problem? Should I add something in my code to deal with this?</p>