Skip to content

Commit 30352bb

Browse files
authored
Merge pull request #410 from KuroKoka551/feature/groups
Fix not released lock
2 parents 5fb9563 + 9dfbd8b commit 30352bb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/aiogram_dialog/context/intent_middleware.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ async def _load_context_by_stack(
104104
if stack.empty():
105105
context = None
106106
else:
107-
context = await proxy.load_context(stack.last_intent_id())
107+
try:
108+
context = await proxy.load_context(stack.last_intent_id())
109+
except:
110+
await proxy.unlock()
111+
raise
108112
data[STORAGE_KEY] = proxy
109113
data[STACK_KEY] = stack
110114
data[CONTEXT_KEY] = context
@@ -126,7 +130,11 @@ async def _load_context_by_intent(
126130
stack = await self._load_stack(event, context.stack_id, proxy, data)
127131
if not stack:
128132
return
129-
self._check_outdated(intent_id, stack)
133+
try:
134+
self._check_outdated(intent_id, stack)
135+
except:
136+
await proxy.unlock()
137+
raise
130138

131139
data[STORAGE_KEY] = proxy
132140
data[STACK_KEY] = stack

0 commit comments

Comments
 (0)