Adding the timeout for the connection on the configuration database.

While accessing the configuration database from multiple session, it
results in to the error - OperationError, because - sqlite locks all the
database, and does not allow to access it simultaneously. We added the
timeout to give some time window for accessing it simultaneously.
This commit is contained in:
Ashesh Vashi 2016-05-10 15:58:59 +05:30
parent 8cfca280d4
commit d8cbee3850
2 changed files with 8 additions and 3 deletions

View File

@ -160,6 +160,10 @@ SQLITE_PATH = os.path.join(
os.path.realpath(os.path.expanduser('~/.pgadmin/')), os.path.realpath(os.path.expanduser('~/.pgadmin/')),
'pgadmin4.db' 'pgadmin4.db'
) )
# SQLITE_TIMEOUT will define how long to wait before throwing the error -
# OperationError due to database lock.
# (Default: 500 milliseconds)
SQLITE_TIMEOUT = 500
########################################################################## ##########################################################################
# Server-side session storage path # Server-side session storage path

View File

@ -169,9 +169,10 @@ def create_app(app_name=config.APP_NAME):
# Setup authentication # Setup authentication
########################################################################## ##########################################################################
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{0}'.format( app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{0}?timeout={1}'.format(
config.SQLITE_PATH.replace('\\', '/') config.SQLITE_PATH.replace('\\', '/'),
) getattr(config, 'SQLITE_TIMEOUT', 500)
)
# Only enable password related functionality in server mode. # Only enable password related functionality in server mode.
if config.SERVER_MODE is True: if config.SERVER_MODE is True: