@@ -561,16 +561,14 @@ def process_advance_block_retry( # noqa: C901
561561 if requirements_satisfied is False :
562562 continue
563563 break
564+ except KeyboardInterrupt as exc :
565+ raise exc from exc
564566 except Exception as exc :
565- err_msg = traceback .format_exc ()
566- do_retry = (
567- block .retry
568- and trial_idx + 1 < trial_total
569- and "Keyboard Interrupt" not in err_msg
570- )
567+ do_retry = block .retry and trial_idx + 1 < trial_total
571568 if block .fallback is None and not do_retry :
572569 raise exc from exc
573570 if do_retry :
571+ err_msg = traceback .format_exc ()
574572 error = f"An error occurred in a PDL block. Error details: { err_msg } "
575573 print (
576574 f"\n \033 [0;31m[Retry { trial_idx + 1 } /{ max_retry } ] { error } \033 [0m\n " ,
@@ -1395,14 +1393,15 @@ def process_blocks( # pylint: disable=too-many-arguments,too-many-positional-ar
13951393 saved_background : LazyMessages = DependentContext ([])
13961394 trace = []
13971395 pdl_context_init : LazyMessages = scope .data ["pdl_context" ]
1396+ is_last_of = isinstance (join_type , JoinLastOf )
13981397 try :
13991398 for i , block in enumerate (blocks ):
14001399 iteration_state = iteration_state_init .with_iter (i )
14011400 scope = scope | {
14021401 "pdl_context" : DependentContext ([pdl_context_init , background ])
14031402 }
14041403 new_loc = append (loc , "[" + str (i ) + "]" )
1405- if isinstance ( join_type , JoinLastOf ) and state .yield_result :
1404+ if is_last_of and state .yield_result :
14061405 iteration_state = state .with_yield_result (i + 1 == len (blocks ))
14071406 (
14081407 iteration_result ,
0 commit comments