@@ -449,7 +449,6 @@ def __init__(
449
449
self .task_unique = trig_cfg .get ("task_unique" , {}).get ("args" , None )
450
450
self .task_unique_kwargs = trig_cfg .get ("task_unique" , {}).get ("kwargs" , None )
451
451
self .action = trig_cfg .get ("action" )
452
- self .action_ast_ctx = trig_cfg .get ("action_ast_ctx" )
453
452
self .global_sym_table = trig_cfg .get ("global_sym_table" , {})
454
453
self .notify_q = asyncio .Queue (0 )
455
454
self .active_expr = None
@@ -622,14 +621,22 @@ async def trigger_watch(self):
622
621
)
623
622
continue
624
623
624
+ action_ast_ctx = AstEval (
625
+ f"{ self .action .global_ctx_name } .{ self .action .name } " , self .action .global_ctx
626
+ )
627
+ Function .install_ast_funcs (action_ast_ctx )
628
+ task_unique_func = None
629
+ if self .task_unique is not None :
630
+ task_unique_func = Function .task_unique_factory (action_ast_ctx )
631
+
625
632
#
626
633
# check for @task_unique with kill_me=True
627
634
#
628
635
if (
629
636
self .task_unique is not None
630
637
and self .task_unique_kwargs
631
638
and self .task_unique_kwargs ["kill_me" ]
632
- and Function .unique_name_used (self . action_ast_ctx , self .task_unique )
639
+ and Function .unique_name_used (action_ast_ctx , self .task_unique )
633
640
):
634
641
_LOGGER .debug (
635
642
"trigger %s got %s trigger, @task_unique kill_me=True prevented new action" ,
@@ -652,14 +659,6 @@ async def do_func_call(func, ast_ctx, task_unique, task_unique_func, **kwargs):
652
659
if ast_ctx .get_exception_obj ():
653
660
ast_ctx .get_logger ().error (ast_ctx .get_exception_long ())
654
661
655
- action_ast_ctx = AstEval (
656
- f"{ self .action .global_ctx_name } .{ self .action .name } " , self .action .global_ctx
657
- )
658
- Function .install_ast_funcs (action_ast_ctx )
659
- task_unique_func = None
660
- if self .task_unique :
661
- task_unique_func = Function .task_unique_factory (action_ast_ctx )
662
-
663
662
Function .create_task (
664
663
do_func_call (
665
664
self .action , action_ast_ctx , self .task_unique , task_unique_func , ** func_args
0 commit comments