keep a continuous mongo connection active using pymongo
From the documentation of pymongo.mongo_client.MongoClient
If an operation fails because of a network error, ConnectionFailure is raised and the client reconnects in the background. Application code should handle this exception (recognizing that the operation failed) and then continue to execute.
I don't think you need to implement your own re-connection method.