title: How can I force pymongo to close sockets?
body: <p>I'm currently working on distributed computing.
  My workers returns its results by inserting it into a mongoDB database.The code works well,but the connection remains opened and at a moment my system run out of sockets.
  Here is my worker code:</p>
  
  <pre><code>def worker(elt):
      client=pymongo.MongoClient(MONGODB_URI)
      db = client.get_default_database()
      essaiElt = db['essaiElt']
      #compute here
      essaiElt.insert( elt.toDict())
      client.close()
  </code></pre>
  
  <p>By using this command "netstat -anbo" I can see all sockets still opened (more than 3000), the max number of worker is 14 but they have to deal with more than 10 000 task.</p>
  
  <pre><code>...
  TCP 10.130.151.11:4999 10.130.137.128:27017 En attente 0
  TCP 10.130.151.11:5000 10.130.137.128:27017 En attente 0
  </code></pre>
  
  <p>I've tried to set timeouts but it doesn't have any effect.</p>
  
  <p>How can I close sockets without restart my dataBase?</p>
  
  <p>Python 2.7.12
  Pymongo 3.3
  mongoDB 3.2.10</p>