Commit 95c33501 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Applied mongo connection fix.

parent 57bea61f
Pipeline #65662 passed with stages
in 22 minutes and 26 seconds
......@@ -28,7 +28,8 @@ from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from elasticsearch.exceptions import RequestError
from elasticsearch_dsl import connections
from mongoengine import connect
from mongoengine import connect, disconnect
from mongoengine.connection import MongoEngineConnectionError
from passlib.hash import bcrypt
import smtplib
from email.mime.text import MIMEText
......@@ -80,7 +81,12 @@ def setup_logging():
def setup_mongo():
""" Creates connection to mongodb. """
global mongo_client
mongo_client = connect(db=config.mongo.db_name, host=config.mongo.host, port=config.mongo.port)
try:
mongo_client = connect(db=config.mongo.db_name, host=config.mongo.host, port=config.mongo.port)
except MongoEngineConnectionError:
disconnect()
mongo_client = connect(db=config.mongo.db_name, host=config.mongo.host, port=config.mongo.port)
logger.info('setup mongo connection')
return mongo_client
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment