[sqlalchemy] Auto delete session key only if key present
@@ -221,7 +221,7 @@ class SqlAlchemyApi(Api):
connection = engine.connect()
except Exception as e:
engine_key = self._get_engine_key()
- del ENGINES[engine_key]
+ ENGINES.pop(engine_key, None)
raise AuthenticationRequired(message='Could not establish connection to datasource')
