【发布时间】:2020-02-12 14:36:19
【问题描述】:
在我的散景服务器上,单击按钮会进行耗时的计算。在计算期间,我想将按钮涂成红色并将标签更改为“正在进行分析”。这适用于我笔记本电脑上的以下脚本。 但是,当我使用我拥有的桌面作为服务器时,完全相同的脚本无法正常工作。当首先在该服务器上运行脚本时,计算完成,然后按钮变为红色,然后立即变为绿色。
简化的脚本:
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)
我的笔记本电脑:
- python 3.6
- 散景 1.4.0
- Intel(R) Xeon(R) CPU E3-1575M v5 3.00GHz, 32.0GB 内存
- 64 位 Windows 10
我的桌面:
- python 3.7
- 散景 1.4.0
- Intel(R) Xeon(R) E-2174G CPU @ 3.80GHz,16.0GB RAM
- 64 位 Windows 10
我已经在 Chrome、Edge 和 IE11 中进行了测试。此外,当从我的笔记本电脑访问我桌面上的服务器时,我注意到了同样的问题。因此我认为这是一个服务器端问题。
感谢您对此的假设,以及关于如何表示正在进行的工作的替代方案。
(您在 cmd 中通过 bokeh serve button.py --show 运行脚本)
【问题讨论】:
标签: javascript python asynchronous callback bokeh