odmantic icon indicating copy to clipboard operation
odmantic copied to clipboard

Check connection to db

Open tobiasz-gleba opened this issue 4 years ago • 3 comments

How to check connection to mongoDB using odmantic?

tobiasz-gleba avatar Nov 26 '20 22:11 tobiasz-gleba

Hello, you mean to check if the mongo server is up ?

art049 avatar Nov 30 '20 18:11 art049

yup

tobiasz-gleba avatar Dec 01 '20 13:12 tobiasz-gleba

Right now, there is nothing unfortunately. If the database is not there, the motor_client will hang. This is the default behavior of motor but it would be possible to add the connectTimeoutMS kwarg while building the motor client. Normally, this should default to 20 seconds (as mentionned in the pymongo docs) but i'm not sure this is the case with the default parameters of motor.

Anyway, for now you can create manually the motor client, passing it the connectTimeoutMS you want. Then you'll be able to create the engine from this existing client :smile:

art049 avatar Dec 01 '20 17:12 art049