diff --git a/iceprod/credentials/server.py b/iceprod/credentials/server.py index 915711a46..1f1ed174b 100644 --- a/iceprod/credentials/server.py +++ b/iceprod/credentials/server.py @@ -425,6 +425,8 @@ def __init__(self): 'TOKEN_EXPIRE_BUFFER': 24.0, 'TOKEN_SERVICE_CHECK_INTERVAL': 180, 'DB_URL': 'mongodb://localhost/creds', + 'DB_TIMEOUT': 60, + 'DB_WRITE_CONCERN': 1, 'STATSD_ADDRESS': '', 'STATSD_PREFIX': 'credentials', 'CI_TESTING': '', @@ -466,7 +468,11 @@ def __init__(self): logging_url = config["DB_URL"].split('@')[-1] if '@' in config["DB_URL"] else config["DB_URL"] logging.info(f'DB: {logging_url}') db_url, db_name = config['DB_URL'].rsplit('/', 1) - db = motor.motor_asyncio.AsyncIOMotorClient(db_url) + db = motor.motor_asyncio.AsyncIOMotorClient( + db_url, + timeoutMS=config['DB_TIMEOUT'], + w=config['DB_WRITE_CONCERN'], + ) logging.info(f'DB name: {db_name}') self.db = db[db_name] self.indexes = { diff --git a/iceprod/materialization/server.py b/iceprod/materialization/server.py index 4776055a0..b69cad45b 100644 --- a/iceprod/materialization/server.py +++ b/iceprod/materialization/server.py @@ -277,6 +277,8 @@ def __init__(self): 'ICEPROD_API_CLIENT_ID': '', 'ICEPROD_API_CLIENT_SECRET': '', 'DB_URL': 'mongodb://localhost/datasets', + 'DB_TIMEOUT': 60, + 'DB_WRITE_CONCERN': 1, 'STATSD_ADDRESS': '', 'STATSD_PREFIX': 'rest_api', 'CI_TESTING': '', @@ -318,7 +320,11 @@ def __init__(self): logging_url = config["DB_URL"].split('@')[-1] if '@' in config["DB_URL"] else config["DB_URL"] logging.info(f'DB: {logging_url}') db_url, db_name = config['DB_URL'].rsplit('/', 1) - db = motor.motor_asyncio.AsyncIOMotorClient(db_url) + db = motor.motor_asyncio.AsyncIOMotorClient( + db_url, + timeoutMS=config['DB_TIMEOUT'], + w=config['DB_WRITE_CONCERN'], + ) logging.info(f'DB name: {db_name}') self.db = db[db_name] self.indexes = {