mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-14 19:44:25 +00:00
17 lines
422 B
Python
17 lines
422 B
Python
|
"""Db_helper."""
|
||
|
import sqlalchemy
|
||
|
from flask_bpmn.models.db import db
|
||
|
import time
|
||
|
|
||
|
|
||
|
def try_to_connect(start_time: float) -> None:
|
||
|
"""Try to connect."""
|
||
|
try:
|
||
|
db.first_or_404("select 1") # type: ignore
|
||
|
except sqlalchemy.exc.DatabaseError as exception:
|
||
|
if time.time() - start_time > 15:
|
||
|
raise exception
|
||
|
else:
|
||
|
time.sleep(1)
|
||
|
try_to_connect(start_time)
|