summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/asyncio/events.py
blob: e3d8456908cf8ecfe557e9ca9245b8e50bce6a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# ext/asyncio/events.py
# Copyright (C) 2020-2021 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: https://www.opensource.org/licenses/mit-license.php

from .engine import AsyncConnectable
from .session import AsyncSession
from ...engine import events as engine_event
from ...orm import events as orm_event


class AsyncConnectionEvents(engine_event.ConnectionEvents):
    _target_class_doc = "SomeEngine"
    _dispatch_target = AsyncConnectable

    @classmethod
    def _listen(cls, event_key, retval=False):
        raise NotImplementedError(
            "asynchronous events are not implemented at this time.  Apply "
            "synchronous listeners to the AsyncEngine.sync_engine or "
            "AsyncConnection.sync_connection attributes."
        )


class AsyncSessionEvents(orm_event.SessionEvents):
    _target_class_doc = "SomeSession"
    _dispatch_target = AsyncSession

    @classmethod
    def _listen(cls, event_key, retval=False):
        raise NotImplementedError(
            "asynchronous events are not implemented at this time.  Apply "
            "synchronous listeners to the AsyncSession.sync_session."
        )