how to use on_kernel_start
I want to initial some data, when I run in notebook thsee code works, but when deploy in py these doesn't work!
if Record_initialing.value:
# print('检测执行情况')
set_roundinfo(latestround)
dfRBI=RecalUIDataFrame(dfroundbattleinfo,False) # print(dfRBI) UpdateGraphic(dfRBI.copy()) UpdateUIDataFrame(dfRBI.copy())
#更新画图,记录也执行一次显示出表头? Record_initialing.value=False I copy those into standalone @solara.lab.on_kernel_start def pageinitial(): and it go wrong with function undefined I move on_kernel_start back to the page and it doesn't work. How to use kernel_start?
dfRBI=RecalUIDataFrame(dfroundbattleinfo,False) # print(dfRBI) UpdateGraphic(dfRBI.copy()) UpdateUIDataFrame(dfRBI.copy())
#更新画图,记录也执行一次显示出表头? Record_initialing.value=False I copy those into standalone @solara.lab.on_kernel_start def pageinitial(): and it go wrong with function undefined I move on_kernel_start back to the page and it doesn't work. How to use kernel_start?
2 Replies
I am trying to work with this, because the following initial method go wrong when auto reload. the bNeedinitial.value is set to False.
if bNeedinitial.value:
bili=BILI_tools(DataSource,database_path,readed_fav_id,unread_fav_id,plan_fav_id,temp_fav_id,output_handler=print_ui,StandardMode=False)
timer1 = BiliTimer(bili.get_plan_list,1,1,1,hintmsg='开始加载计划清单',strmark='计划清单',output_handler=print_ui)
timer2 = BiliTimer(bili.get_todo_list,1.5,1.5,1,hintmsg='开始加载待办清单',strmark='待办清单',output_handler=print_ui)
timer = BiliTimer(bili.fav_to_database,scheduletime=scheduletime,output_handler=print_ui)
bNeedinitial.value=False
but there is some other problem, the timer is a thread loop class, after I add the line to solara , I can't use ctrl+c to end prompt cmd, it hold here with no hint.
self.timer_thread = threading.Thread(target=self.start)
self.timer_thread.start()