Added tenacity retry fir migrations connection

master
Ionut Filip 6 years ago
parent bdcf69b0e6
commit 7b8835070d

@ -3,6 +3,8 @@ from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
import logging
import tenacity
from tenacity import retry
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
@ -68,8 +70,8 @@ def run_migrations_online():
engine = engine_from_config(config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = retry(engine.connect, stop=tenacity.stop_after_attempt(100), wait=tenacity.wait_random(min=2, max=5))()
connection = engine.connect()
context.configure(connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,

@ -46,3 +46,4 @@ WTForms==2.2.1
WTForms-Components==0.10.3
psycopg2
sqlalchemy-citext
tenacity

@ -17,3 +17,4 @@ PyYAML
PyOpenSSL
dnspython
bcrypt
tenacity

Loading…
Cancel
Save