Is there a function that can immediately synchronize data to the vue data without waiting for the flush time to update? #478
-
I have a function, to calculate a object volume by Layer. so, I prepared a callback function that can retrieve the current computation progress, However, when I try to update the progress using It still waits until the Is there any way to immediately update the vue data by wslink? def callback(progress):
server.state.progress_info = int(progress * 100)
server.state.dirty("progress_info")
server.state.flush()
def cal_layer_distribution(mesh:pv.DataSet, ids:list[int]=None, callback:Callable=None) -> tuple[float, dict]:
layer_distribution = {}
total_volume = abs(mesh.volume)
total_progress = len(ids)
if "Layer" not in mesh.array_names:
raise ValueError("Array named 'Layer' is not in the current mesh!")
for layer_id in ids:
callback(layer_id/total_progress)
volume = abs(mesh.threshold((layer_id, layer_id), scalars="Layer").volume) # The steps that take the most time
layer_distribution[layer_id] = {"volume": volume, "percentage": volume/total_volume}
callback(1)
return (total_volume, layer_distribution) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
In short if you are locking the main thread from asyncio and therefore, you are just stacking the network requests without giving it any room to be managed right away. |
Beta Was this translation helpful? Give feedback.
#453