2022-10-17 02:31:55 +00:00
|
|
|
"""Grabs tickets from csv and makes process instances."""
|
2022-10-18 11:09:03 +00:00
|
|
|
import time
|
2022-10-17 02:31:55 +00:00
|
|
|
|
|
|
|
import sqlalchemy
|
2022-10-18 11:09:03 +00:00
|
|
|
from flask_bpmn.models.db import db
|
|
|
|
|
|
|
|
from spiffworkflow_backend import get_hacked_up_app_for_script
|
2022-10-17 02:31:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
def try_to_connect(start_time: float) -> None:
|
2022-10-18 11:09:03 +00:00
|
|
|
"""Try to connect."""
|
2022-10-17 02:31:55 +00:00
|
|
|
try:
|
2022-10-18 11:09:03 +00:00
|
|
|
db.first_or_404("select 1")
|
2022-10-17 02:31:55 +00:00
|
|
|
except sqlalchemy.exc.DatabaseError as exception:
|
|
|
|
if time.time() - start_time > 15:
|
|
|
|
raise exception
|
|
|
|
else:
|
|
|
|
time.sleep(1)
|
|
|
|
try_to_connect(start_time)
|
|
|
|
|
2022-10-18 11:09:03 +00:00
|
|
|
|
2022-10-17 02:31:55 +00:00
|
|
|
def main() -> None:
|
|
|
|
"""Main."""
|
|
|
|
app = get_hacked_up_app_for_script()
|
|
|
|
start_time = time.time()
|
|
|
|
with app.app_context():
|
|
|
|
try_to_connect(start_time)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|