在我的bokeh服务器上,单击一个按钮会进行大量时间的计算。在计算期间,我要将按钮颜色设为红色,并将标签更改为“进行中的分析”。这与我的笔记本电脑上的以下脚本配合得很好。 但是,当我使用自己拥有的台式机作为服务器时,完全相同的脚本无法正常工作。在该服务器上运行脚本时,首先完成计算,然后仅在瞬间按钮变为红色,然后立即再次变为绿色。
简化脚本:
from bokeh.models import Button
from bokeh.io import curdoc
import time
def callback():
button.button_type="danger"#signal work in progress via the button style
button.label="Analysis in progress, please wait.."
time.sleep(3)#or do some computation that takes time
button.button_type="success"#signal the analysis is done via the button style
button.label="Analysis Done"
button = Button(label='Analyze',button_type="success", width=500)
button.on_click(callback)
curdoc().add_root(button)
我的笔记本电脑:
我的桌面:
我已经在Chrome,Edge和IE11中进行了测试。另外,从笔记本电脑访问台式机上的服务器时,我注意到相同的问题。因此,我认为这是服务器端的问题。
您对此的假设以及有关如何发出进行中信号的替代方法的赞赏。
(您在cmd中通过bokeh serve button.py --show
来运行脚本)
散景取决于龙卷风。在两台PC上,龙卷风版本都不同。将龙卷风版本从6.0.2降级到5.0.2解决了该问题。
pip install tornado==5.0.2