Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions libraries/botbuilder-core/botbuilder/core/turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,15 @@ async def _emit(self, plugins, arg, logic):

async def emit_next(i: int):
context = self
try:
if i < len(handlers):

async def next_handler():
await emit_next(i + 1)

await handlers[i](context, arg, next_handler)

except Exception as error:
raise error

await emit_next(0)
# logic does not use parentheses because it's a coroutine
return await logic
if i < len(handlers):
try:
return await handlers[i](context, arg, lambda: emit_next(i + 1))
except Exception as error:
raise error
else:
return await logic

return await emit_next(0)

async def send_trace_activity(
self, name: str, value: object = None, value_type: str = None, label: str = None
Expand Down
2 changes: 1 addition & 1 deletion libraries/botbuilder-core/tests/test_turn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ async def update_handler(context, activity, next_handler_coroutine):
assert context is not None
assert activity.id == activity_id
assert activity.conversation.id == ACTIVITY.conversation.id
await next_handler_coroutine()
return await next_handler_coroutine()

context.on_update_activity(update_handler)
new_activity = MessageFactory.text("test text")
Expand Down