88from typing import List , Union
99
1010from mcdreforged .api .all import *
11+
1112from ruamel import yaml
1213
1314from hooks .utils import *
@@ -61,7 +62,6 @@ def __init__(self, name, task_type, created_by, command):
6162
6263 command : str = ''
6364
64- @new_thread ('hooks - execute' )
6565 def execute_task (self , server : PluginServerInterface , hook : str , var_dict : dict = None , obj_dict : dict = None ):
6666 server .logger .debug (f'Executing task: { self .task_name } , task_type: { self .task_type } , command: { self .command } ' )
6767 server .logger .debug (f'objects_dict: { str (var_dict )} ' )
@@ -119,15 +119,15 @@ def execute_task(self, server: PluginServerInterface, hook: str, var_dict: dict
119119 # python code
120120 elif self .task_type == TaskType .python_code :
121121 if obj_dict is not None :
122- exec (self .command , obj_dict , {} )
122+ exec (self .command , {}, obj_dict )
123123 else :
124124 if var_dict is not None :
125- exec (self .command , var_dict , locals () )
125+ exec (self .command , {}, var_dict )
126126 else :
127- exec (self .command , globals () , locals ())
127+ exec (self .command , {} , locals ())
128128
129- server .logger .debug (f'Task finished, name: { self .task_name } , task_type: { self .task_type } , command: { self . command } , '
130- f'costs { time .time () - start_time } seconds.' )
129+ server .logger .debug (f'Task finished, name: { self .task_name } , task_type: { self .task_type } , '
130+ f'command: { self . command } , costs { time .time () - start_time } seconds.' )
131131
132132
133133def stop_all_schedule_daemon_threads ():
@@ -142,7 +142,7 @@ def stop_all_schedule_daemon_threads():
142142class AThread (threading .Thread ):
143143 def init_thread (self ):
144144 super ().__init__ (daemon = True )
145-
145+
146146 def set_thread_name (self , name : str ):
147147 self .name = name
148148
0 commit comments