##// END OF EJS Templates
fix(celery): use a lightweight method of db ping to speed up tasks executions
super-admin -
r5290:2ffa4031 default
parent child Browse files
Show More
@@ -116,14 +116,19 b' def parse_ini_vars(ini_vars):'
116
116
117
117
118 def ping_db():
118 def ping_db():
119 from rhodecode.model import meta
120 from rhodecode.model.db import DbMigrateVersion
121 log.info('Testing DB connection...')
119 log.info('Testing DB connection...')
122
120
121 from sqlalchemy import text
122 from rhodecode.model import meta
123 qry = text("SELECT user_id from users where username = :uname")
123 for test in range(10):
124 for test in range(10):
124 try:
125 try:
125 scalar = DbMigrateVersion.query().scalar()
126 engine = meta.get_engine()
126 log.debug('DB PING %s@%s', scalar, scalar.version)
127 with meta.SA_Session(engine) as session:
128 result = session.execute(qry, {'uname': 'default'})
129 user_id = result.first()[0]
130
131 log.debug('DB PING user_id:%s', user_id)
127 break
132 break
128 except Exception:
133 except Exception:
129 retry = 1
134 retry = 1
General Comments 0
You need to be logged in to leave comments. Login now