You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a How to guide for Panel+Dask in #4234.
I have created an async example. The problem is that the await operation only finishes after a very long time or very quickly if I drag an independent slider.
fromdatetimeimportdatetimeasdtimportparamfromdask.distributedimportClientfromtasksimportblocking_computationimportpanelaspnpn.extension()
@pn.cachedefget_client():
returnClient()
get_client() # For some unknown reason this is needed. Otherwise we get ModuleNotFoundError: No module named 'panel_dask_cluster'asyncdefsubmit(func, *args, **kwargs):
client=get_client()
future=client.submit(func, *args, **kwargs)
returnawaitclient.gather(future, asynchronous=True)
float_input=pn.widgets.FloatInput(value=0, name="Input")
submit_button=pn.widgets.Button(name="Run in background", button_type="primary")
other_widget=pn.widgets.IntSlider(value=0, start=0, end=10, name="Non blocked slider")
pn.Column(float_input, submit_button, other_widget, other_widget.param.value).servable()
defstart():
submit_button.disabled=Truefloat_input.disabled=Truefloat_input.loading=Truedefstop():
float_input.disabled=Falsefloat_input.loading=Falsesubmit_button.disabled=False@pn.depends(submit_button, watch=True)asyncdefrun(_):
start()
s1=dt.now()
print("stop", s1)
float_input.value=awaitsubmit(blocking_computation, float_input.value)
s2=dt.now()
print("stop", s2)
print("total duration", (s2-s1))
stop()
panel serve app.py
You can see in the video that the async operation finishes after ~10secs. Most of the time (~9secs) is spent after the heavy_computation run by dask has finished. If I drag the slider you can see it finishing after ~1sec.
strange_panel_dask.mp4
The text was updated successfully, but these errors were encountered:
I found out that if I start the Dask server in a separate python file/process then I don't experience this. I also experience other issues when starting the server from the same file as the panel serve.
I believe we should just instruct Panel+Dask users to seperate the things. This will make things simpler.
I'm trying to create a How to guide for Panel+Dask in #4234.
I have created an async example. The problem is that the
await
operation only finishes after a very long time or very quickly if I drag an independent slider.tasks.py
app.py
You can see in the video that the async operation finishes after ~10secs. Most of the time (~9secs) is spent after the
heavy_computation
run by dask has finished. If I drag the slider you can see it finishing after ~1sec.strange_panel_dask.mp4
The text was updated successfully, but these errors were encountered: