Search code examples
flaskpymongouwsgiflask-mongoengine

MongoClient opened before fork. Create MongoClient only Flask


I am running Flask with uwsgi threaded mode with processes 4 and using pymongo also flask_mongoengine and uwsgi says "MongoClient opened before fork. Create MongoClient only " I tried connect with connect=False but the result is same

lazy-apps = true problem is fixed but it seems that uwsgi needs more time to load what can be done for best performance ?


Solution

  • app.config['MONGODB_SETTINGS'] = {'DB': 'somedb', "USERNAME": "dbadmin", "PASSWORD":"somepass",'connect': False}

    And

    client = MongoClient(connect=False, username='dbadmin', password='somepass', authSource='somedb')

    Solutions for Mongoengine and For pymongo