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/event | |
| 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/event')
| -rw-r--r-- | lib/sqlalchemy/event/api.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/event/base.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/sqlalchemy/event/api.py b/lib/sqlalchemy/event/api.py index 52f796b19..c853d1f5e 100644 --- a/lib/sqlalchemy/event/api.py +++ b/lib/sqlalchemy/event/api.py @@ -29,7 +29,7 @@ def _event_key( target: _ET, identifier: str, fn: _ListenerFnType ) -> _EventKey[_ET]: for evt_cls in _registrars[identifier]: - tgt = evt_cls._accept_with(target) + tgt = evt_cls._accept_with(target, identifier) if tgt is not None: return _EventKey(target, identifier, fn, tgt) else: diff --git a/lib/sqlalchemy/event/base.py b/lib/sqlalchemy/event/base.py index 83b34a17f..7db3a4f6c 100644 --- a/lib/sqlalchemy/event/base.py +++ b/lib/sqlalchemy/event/base.py @@ -250,7 +250,7 @@ class _HasEventsDispatch(Generic[_ET]): @classmethod def _accept_with( - cls, target: Union[_ET, Type[_ET]] + cls, target: Union[_ET, Type[_ET]], identifier: str ) -> Optional[Union[_ET, Type[_ET]]]: raise NotImplementedError() @@ -334,7 +334,7 @@ class Events(_HasEventsDispatch[_ET]): @classmethod def _accept_with( - cls, target: Union[_ET, Type[_ET]] + cls, target: Union[_ET, Type[_ET]], identifier: str ) -> Optional[Union[_ET, Type[_ET]]]: def dispatch_is(*types: Type[Any]) -> bool: return all(isinstance(target.dispatch, t) for t in types) |
