diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-30 12:29:58 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-31 15:06:28 -0400 |
| commit | ad14471bc99c2fb2315d3333a95dd3d7bf0a33a7 (patch) | |
| tree | 8eb1feafcd1fcc73437363ca22be536a6de79f77 /lib/sqlalchemy/orm/events.py | |
| parent | d97de97eff21af3bdacffc2b625feb7e0bd6c18c (diff) | |
| download | sqlalchemy-ad14471bc99c2fb2315d3333a95dd3d7bf0a33a7.tar.gz | |
Support handle_error for pre_ping
The :meth:`.DialectEvents.handle_error` event is now moved to the
:class:`.DialectEvents` suite from the :class:`.EngineEvents` suite, and
now participates in the connection pool "pre ping" event for those dialects
that make use of disconnect codes in order to detect if the database is
live. This allows end-user code to alter the state of "pre ping". Note that
this does not include dialects which contain a native "ping" method such as
that of psycopg2 or most MySQL dialects.
Fixes: #5648
Change-Id: I353d84a4f66f309d2467b7e67621db6b8c70411e
Diffstat (limited to 'lib/sqlalchemy/orm/events.py')
| -rw-r--r-- | lib/sqlalchemy/orm/events.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py index 726ea79b5..7cc0aa9c9 100644 --- a/lib/sqlalchemy/orm/events.py +++ b/lib/sqlalchemy/orm/events.py @@ -62,7 +62,7 @@ class InstrumentationEvents(event.Events): _dispatch_target = instrumentation.InstrumentationFactory @classmethod - def _accept_with(cls, target): + def _accept_with(cls, target, identifier): if isinstance(target, type): return _InstrumentationEventsHold(target) else: @@ -203,7 +203,7 @@ class InstanceEvents(event.Events): @classmethod @util.preload_module("sqlalchemy.orm") - def _accept_with(cls, target): + def _accept_with(cls, target, identifier): orm = util.preloaded.orm if isinstance(target, instrumentation.ClassManager): @@ -705,7 +705,7 @@ class MapperEvents(event.Events): @classmethod @util.preload_module("sqlalchemy.orm") - def _accept_with(cls, target): + def _accept_with(cls, target, identifier): orm = util.preloaded.orm if target is orm.mapper: @@ -1383,7 +1383,7 @@ class SessionEvents(event.Events[Session]): return fn @classmethod - def _accept_with(cls, target): + def _accept_with(cls, target, identifier): if isinstance(target, scoped_session): target = target.session_factory @@ -1409,7 +1409,7 @@ class SessionEvents(event.Events[Session]): target._no_async_engine_events() else: # allows alternate SessionEvents-like-classes to be consulted - return event.Events._accept_with(target) + return event.Events._accept_with(target, identifier) @classmethod def _listen( @@ -2263,7 +2263,7 @@ class AttributeEvents(event.Events): return dispatch @classmethod - def _accept_with(cls, target): + def _accept_with(cls, target, identifier): # TODO: coverage if isinstance(target, interfaces.MapperProperty): return getattr(target.parent.class_, target.key) |
