title: Query to mongodb stuck if the cluster primary lost network (using PyMongo)
body: <p>I have a problem regarding mongo. Here is my setup:</p>
  <ul>
  <li>3 mongod with replica set on 3 different virtual machine</li>
  <li>1 mongo-configsvr on each of the 3 previous VM</li>
  <li>1 mongos on the client VM to route to the 3 mongod</li>
  <li>A soft developed in Python (with PyMongo)</li>
  </ul>
  <p>Now, my problem. I'm developing a software that request a lot mongo. The problem appeared when my primary mongod VM lost network. At this time, the request that was last sent was stuck.
  By stuck I mean that the request wont work, but will not raise any &quot;AutoReconnect&quot; to let me do the request again so it can route to the new primary.
  The request is totally stucked, it will raise an error after 15 minutes OR if the network goes up again on the previous primary.</p>
  <p>I wrote a script to explain the problem:</p>
  <pre><code>#!/usr/bin/python
  # -*- coding: utf-8 -*-
  
  import sys
  import threading
  import time
  from pymongo import MongoClient
  
  def main():
      
      mongo_client = MongoClient()
      db = mongo_client.test
      collection = db['test']
      collection.drop()
      collection = db['test']
      print u'Connected; lets go !'
      while True:
          t0 = time.time()
          collection.insert({'time': time.time()})
          print u'Wait [%03.6f] | There is %s items in test collection' % ((time.time() - t0), collection.count())
          print u'---------------------------------------------------------------'
          time.sleep(1)
  
  main()
  </code></pre>
  <p>As you can see in the code, I do one request per second. So I let the script run, and then I remove the ethernet cable on the primary. The script stuck at the insert, the print will not be printed until the ethernet cable is put back or after 15 minutes.</p>
  <p>I can't believe that no one ever had the problem as losing network is not really hard. But I did not found anything using google.</p>
  <p>Hope you will have answers, thank you!</p>