Is it possible for a MongoDB connection to timeout in Python? -
(newbie question, sorry -i'm beginning mongodb)
i connecting mongo on heroku this:
self.connection = pymongo.connection(mongo_url) self.db = self.connection.app13805318
is possible try use self.db after few hours , can't read it? need kind of keepalive or refresh of connection?
citing pymongo documentation: http://api.mongodb.org/python/current/api/pymongo/mongo_client.html#pymongo.mongo_client.mongoclient
the resultant client object has connection-pooling built in. performs auto-reconnection when necessary. if operation fails because of connection error, connectionfailure raised. if auto-reconnection performed, autoreconnect raised. application code should handle exception (recognizing operation failed) , continue execute.
so @james-wahlin suggested in comments, should not solely rely on pymongo's connection-pooling mechanism wrap usage of self.db
in try..except
clauses.
hope helps.
Comments
Post a Comment