mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-13 19:15:31 +00:00
19 lines
482 B
Python
19 lines
482 B
Python
"""Db_helper."""
|
|
import time
|
|
|
|
import sqlalchemy
|
|
from flask_bpmn.models.db import db
|
|
|
|
|
|
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)
|
|
print("Waiting for db to be ready in loop...")
|
|
try_to_connect(start_time)
|