timer_events
attributePT= ParamSpec('PT')attributestop_event= threading.Event()attributetimer_events_tabledict[int, list[tuple[str, Callable, tuple, dict, int]]]= {}attributetimer_event_lock= threading.Lock()functimer_event(t, name=None, thread_priority=ToolDeltaThread.PLUGIN)将修饰器下的方法作为一个定时任务, 每隔一段时间被执行一次。 注意: 请不要在函数内放可能造成堵塞的内容 注意: 当方法被 timer_event 修饰后, 需要调用一次该方法才能开始定时任务线程!
Args: seconds (int): 周期秒数 name (Optional[str], optional): 名字, 默认为自动生成的
@timer_event(60, "定时问好")
def greeting():
print("Hello!")
greeting()paramtintparamnamestr | None= Noneparamthread_priority= ToolDeltaThread.PLUGINReturns
Nonefuncreset()清理所有定时任务
Returns
Nonefuncstopall()Returns
Nonefunctimer_event_boostrap()启动定时任务, 请不要在系统调用以外调用
Returns
Nonefunc_internal_timer_event_boostrap()Returns
None