summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/create.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-08-16 18:07:06 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-08-18 10:41:52 -0400
commit2051fa2ce9e724e6e77e19067d27d2660e7cd74a (patch)
tree5cbff495b520116f4b8bfa35683ef4c1bd681785 /lib/sqlalchemy/engine/create.py
parentd1948bc69bd0d26fbff77d7525ef899a2a9a580d (diff)
downloadsqlalchemy-2051fa2ce9e724e6e77e19067d27d2660e7cd74a.tar.gz
Add new "exec_once_unless_exception" system; apply to dialect.initialize
Fixed an issue whereby if the dialect "initialize" process which occurs on first connect would encounter an unexpected exception, the initialize process would fail to complete and then no longer attempt on subsequent connection attempts, leaving the dialect in an un-initialized, or partially initialized state, within the scope of parameters that need to be established based on inspection of a live connection. The "invoke once" logic in the event system has been reworked to accommodate for this occurrence using new, private API features that establish an "exec once" hook that will continue to allow the initializer to fire off on subsequent connections, until it completes without raising an exception. This does not impact the behavior of the existing ``once=True`` flag within the event system. Fixes: #4807 Change-Id: Iec32999b61b6af4b38b6719e0c2651454619078c
Diffstat (limited to 'lib/sqlalchemy/engine/create.py')
-rw-r--r--lib/sqlalchemy/engine/create.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/create.py b/lib/sqlalchemy/engine/create.py
index cc8304131..72be6009b 100644
--- a/lib/sqlalchemy/engine/create.py
+++ b/lib/sqlalchemy/engine/create.py
@@ -529,7 +529,9 @@ def create_engine(url, **kwargs):
dialect.initialize(c)
dialect.do_rollback(c.connection)
- event.listen(pool, "first_connect", first_connect, once=True)
+ event.listen(
+ pool, "first_connect", first_connect, _once_unless_exception=True
+ )
dialect_cls.engine_created(engine)
if entrypoint is not dialect_cls: