From 2051fa2ce9e724e6e77e19067d27d2660e7cd74a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 16 Aug 2019 18:07:06 -0400 Subject: 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 --- lib/sqlalchemy/engine/create.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/engine/create.py') 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: -- cgit v1.2.1