Skip to content

Commit 7da97db

Browse files
committed
🐛 fix(sqla): workaround for nonebot/nonebot2#2475
1 parent 7577996 commit 7da97db

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

nonebot_plugin_orm/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def _init_orm():
111111
lambda: id(current_event.get(None)),
112112
)
113113

114+
# XXX: workaround for https://github.com/nonebot/nonebot2/issues/2475
115+
event_postprocessor(_clear_scoped_session)
116+
run_postprocessor(_close_scoped_session)
117+
114118

115119
@wraps(lambda: None) # NOTE: for dependency injection
116120
def get_session(**local_kw: Any) -> sa_async.AsyncSession:
@@ -135,13 +139,13 @@ async def get_scoped_session() -> sa_async.async_scoped_session[sa_async.AsyncSe
135139
]
136140

137141

138-
@event_postprocessor
142+
# @event_postprocessor
139143
def _clear_scoped_session(event: Event) -> None:
140144
with suppress(KeyError):
141145
del _scoped_sessions.registry[id(event)]
142146

143147

144-
@run_postprocessor
148+
# @run_postprocessor
145149
async def _close_scoped_session(event: Event, matcher: Matcher) -> None:
146150
with suppress(KeyError):
147151
session: sa_async.AsyncSession = _scoped_sessions.registry[

0 commit comments

Comments
 (0)