@@ -219,50 +219,38 @@ async def cancel_all_dialogs(
219
219
:param event_value:
220
220
:return:
221
221
"""
222
- # pylint: disable=too-many-nested-blocks
223
222
try :
224
- if cancel_parents is None :
225
- event_name = event_name or DialogEvents .cancel_dialog
226
-
227
- if self .stack or self .parent :
228
- # Cancel all local and parent dialogs while checking for interception
229
- notify = False
230
- dialog_context = self
231
-
232
- while dialog_context :
233
- if dialog_context .stack :
234
- # Check to see if the dialog wants to handle the event
235
- if notify :
236
- event_handled = await dialog_context .emit_event (
237
- event_name ,
238
- event_value ,
239
- bubble = False ,
240
- from_leaf = False ,
241
- )
242
-
243
- if event_handled :
244
- break
245
-
246
- # End the active dialog
247
- await dialog_context .end_active_dialog (
248
- DialogReason .CancelCalled
249
- )
250
- else :
251
- dialog_context = (
252
- dialog_context .parent if cancel_parents else None
223
+ event_name = event_name or DialogEvents .cancel_dialog
224
+ if self .stack or self .parent :
225
+ # Cancel all local and parent dialogs while checking for interception
226
+ notify = False
227
+ dialog_context = self
228
+
229
+ while dialog_context :
230
+ if dialog_context .stack :
231
+ # Check to see if the dialog wants to handle the event
232
+ if notify :
233
+ event_handled = await dialog_context .emit_event (
234
+ event_name , event_value , bubble = False , from_leaf = False ,
253
235
)
254
236
255
- notify = True
237
+ if event_handled :
238
+ break
239
+
240
+ # End the active dialog
241
+ await dialog_context .end_active_dialog (
242
+ DialogReason .CancelCalled
243
+ )
244
+ else :
245
+ dialog_context = (
246
+ dialog_context .parent if cancel_parents else None
247
+ )
256
248
257
- return DialogTurnResult (DialogTurnStatus .Cancelled )
258
- # Stack was empty and no parent
259
- return DialogTurnResult (DialogTurnStatus .Empty )
249
+ notify = True
260
250
261
- if self .stack :
262
- while self .stack :
263
- await self .end_active_dialog (DialogReason .CancelCalled )
264
251
return DialogTurnResult (DialogTurnStatus .Cancelled )
265
252
253
+ # Stack was empty and no parent
266
254
return DialogTurnResult (DialogTurnStatus .Empty )
267
255
except Exception as err :
268
256
self .__set_exception_context_data (err )
0 commit comments