How to set connection timeout for Mongodb using pymongo?
So if anyone comes across this later, I was using the wrong option. What I was looking for is serverSelectionTimeoutMS
So if anyone comes across this later, I was using the wrong option. What I was looking for is serverSelectionTimeoutMS
You should be able to escape the password using urllib.quote(). Although you should only quote/escape the password, and exclude the username: ; otherwise the : will also be escaped into %3A. For example: import pymongo import urllib mongo_uri = “mongodb://username:” + urllib.parse.quote(“p@ssword”) + “@127.0.0.1:27001/” client = pymongo.MongoClient(mongo_uri) The above snippet was tested for MongoDB v3.2.x … Read more
We’re investigating this problem, tracked in PYTHON-961. You may be able to work around the issue by passing connect=False when creating instances of MongoClient. That defers background connection until the first database operation is attempted, avoiding what I suspect is a race condition between spin up of MongoClient’s monitor thread and multiprocess forking.