File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 55import common
66import logging
77import functools
8- import threading
98import os
109import requests
1110
12-
1311logger = logging .getLogger ("client" )
1412
13+
1514def show ():
1615 """
1716 Creating a page that shows what devices have been discovered so far
1817 """
1918 toast_obj = st .toast ('Discovering devices...' )
2019 show_list (toast_obj )
2120
22- @functools .lru_cache (maxsize = 1 )
23- def start_inspector_once ():
24- """Initialize the Inspector core only once."""
25- with st .spinner ("Starting API Thread..." ):
26- threading .Thread (
27- target = worker_thread ,
28- daemon = True ,
29- )
30-
3121
3222def worker_thread ():
3323 """
3424 A worker thread to periodically clear the cache of call_predict_api.
3525 """
26+ logger .info ("[Device ID API] Starting worker thread to periodically call the API for each device." )
3627 while True :
3728 time .sleep (15 )
3829 db_conn , rwlock = libinspector .global_state .db_conn_and_lock
@@ -46,6 +37,7 @@ def worker_thread():
4637 with rwlock :
4738 for device_dict in db_conn .execute (sql ):
4839 device_list .append (dict (device_dict ))
40+ logger .info ("[Device ID API] 15 seconds passed, will start calling API for each device if needed." )
4941
5042 # Getting inputs and calling API
5143 for device_dict in device_list :
Original file line number Diff line number Diff line change 1010import functools
1111import common
1212import libinspector .core
13+ import threading
1314
1415
1516def get_page (title , material_icon , show_page_func ):
@@ -74,6 +75,12 @@ def start_inspector_once():
7475 common .config_set ("suppress_warning" , False )
7576 common .config_set ("labeling_in_progress" , False )
7677 libinspector .core .start_threads ()
78+ api_thread = threading .Thread (
79+ name = "Device API Thread" ,
80+ target = device_list_page .worker_thread ,
81+ daemon = True ,
82+ )
83+ api_thread .start ()
7784
7885
7986device_list_page_obj = get_page (
You can’t perform that action at this time.
0 commit comments