Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bokeh] Closing connection: No msgid in header #1148

Closed
maximlt opened this issue Mar 12, 2020 · 11 comments · Fixed by #1170
Closed

[bokeh] Closing connection: No msgid in header #1148

maximlt opened this issue Mar 12, 2020 · 11 comments · Fixed by #1170
Labels
type: bug Something isn't correct or isn't working

Comments

@maximlt
Copy link
Member

maximlt commented Mar 12, 2020

With the following environment on Windows 10...

# packages in environment at C:\Users\maxim\Miniconda3\envs\pluies_poc:
#
# Name                    Version                   Build  Channel
altgraph                  0.16.1                     py_0  
asn1crypto                1.3.0                    py37_0  
atomicwrites              1.3.0                    py37_1  
attrs                     19.3.0                     py_0  
backcall                  0.1.0                    py37_0  
blas                      1.0                         mkl  
bleach                    3.1.0                    py37_0  
bokeh                     1.4.0                    py37_0  
ca-certificates           2020.1.1                      0  
certifi                   2019.11.28               py37_0  
cffi                      1.13.2           py37h7a1dbc1_0  
chardet                   3.0.4                 py37_1003  
colorama                  0.4.3                      py_0  
colorcet                  2.0.2                      py_0    pyviz
cryptography              2.8              py37h7a1dbc1_0  
cycler                    0.10.0                   py37_0  
decorator                 4.4.1                      py_0  
defusedxml                0.6.0                      py_0  
entrypoints               0.3                      py37_0  
freetype                  2.9.1                ha9979f8_1  
future                    0.18.2                   py37_0  
holoviews                 1.12.7                     py_0    pyviz
hvplot                    0.5.2                      py_0    pyviz
hypothesis                5.4.1                      py_0  
icc_rt                    2019.0.0             h0cc432a_1  
icu                       58.2                 ha66f8fd_1  
idna                      2.8                      py37_0  
importlib_metadata        1.4.0                    py37_0  
intel-openmp              2019.4                      245  
ipykernel                 5.1.4            py37h39e3cac_0  
ipython                   7.11.1           py37h39e3cac_0  
ipython_genutils          0.2.0                    py37_0  
ipywidgets                7.5.1                      py_0  
jedi                      0.16.0                   py37_0  
jinja2                    2.10.3                     py_0  
jpeg                      9b                   hb83a4c4_2  
jsonschema                3.2.0                    py37_0  
jupyter                   1.0.0                    py37_7  
jupyter_client            5.3.4                    py37_0  
jupyter_console           6.1.0                      py_0  
jupyter_core              4.6.1                    py37_0  
kiwisolver                1.1.0            py37ha925a31_0  
libpng                    1.6.37               h2a8f88b_0  
libsodium                 1.0.16               h9d3ae62_0  
libtiff                   4.1.0                h56a325e_0  
m2w64-gcc-libgfortran     5.3.0                         6  
m2w64-gcc-libs            5.3.0                         7  
m2w64-gcc-libs-core       5.3.0                         7  
m2w64-gmp                 6.1.0                         2  
m2w64-libwinpthread-git   5.0.0.4634.697f757               2  
macholib                  1.11                       py_0  
markdown                  3.1.1                    py37_0  
markupsafe                1.1.1            py37he774522_0  
matplotlib                3.1.2                    py37_1  
matplotlib-base           3.1.2            py37h64f37c6_1  
mistune                   0.8.4            py37he774522_0  
mkl                       2019.4                      245  
mkl-service               2.3.0            py37hb782905_0  
mkl_fft                   1.0.15           py37h14836fe_0  
mkl_random                1.1.0            py37h675688f_0  
more-itertools            8.0.2                      py_0  
msys2-conda-epoch         20160418                      1  
nbconvert                 5.6.1                    py37_0  
nbformat                  5.0.4                      py_0  
notebook                  6.0.3                    py37_0  
numpy                     1.18.1           py37h93ca92e_0  
numpy-base                1.18.1           py37hc3f5095_1  
olefile                   0.46                     py37_0  
openssl                   1.1.1d               he774522_4  
packaging                 20.1                       py_0  
pandas                    1.0.0            py37h47e9c7a_0  
pandoc                    2.2.3.2                       0  
pandocfilters             1.4.2                    py37_1  
panel                     0.8.0                      py_0    pyviz
param                     1.9.3                      py_0    pyviz
parso                     0.6.0                      py_0  
pefile                    2019.4.18                  py_0  
pickleshare               0.7.5                    py37_0  
pillow                    7.0.0            py37hcc1f983_0  
pip                       20.0.2                   py37_1  
pluggy                    0.13.1                   py37_0  
prometheus_client         0.7.1                      py_0  
prompt_toolkit            3.0.3                      py_0  
py                        1.8.1                      py_0  
pycparser                 2.19                     py37_0  
pycryptodome              3.8.2            py37he774522_0  
pyct                      0.4.6                      py_0    pyviz
pyct-core                 0.4.6                      py_0    pyviz
pygments                  2.5.2                      py_0  
pyinstaller               3.6              py37h2a8f88b_1  
pyopenssl                 19.1.0                   py37_0  
pyparsing                 2.4.6                      py_0  
pyqt                      5.9.2            py37h6538335_2  
pyrsistent                0.15.7           py37he774522_0  
pysocks                   1.7.1                    py37_0  
pytest                    5.3.5                    py37_0  
python                    3.7.6                h60c2a47_2  
python-dateutil           2.8.1                      py_0  
pytz                      2019.3                     py_0  
pyviz_comms               0.7.3                      py_0    pyviz
pywin32                   227              py37he774522_1  
pywin32-ctypes            0.2.0                 py37_1000  
pywinpty                  0.5.7                    py37_0  
pyyaml                    5.2              py37he774522_0  
pyzmq                     18.1.0           py37ha925a31_0  
qt                        5.9.7            vc14h73c81de_0  
qtconsole                 4.6.0                      py_1  
requests                  2.22.0                   py37_1  
send2trash                1.5.0                    py37_0  
setuptools                41.4.0                   py37_0  
sip                       4.19.8           py37h6538335_0  
six                       1.14.0                   py37_0  
sortedcontainers          2.1.0                    py37_0  
sqlite                    3.30.1               he774522_0  
terminado                 0.8.3                    py37_0  
testpath                  0.4.4                      py_0  
tk                        8.6.8                hfa6e2cd_0  
tornado                   6.0.3            py37he774522_0  
tqdm                      4.42.0                     py_0  
traitlets                 4.3.3                    py37_0  
urllib3                   1.25.8                   py37_0  
vc                        14.1                 h0510ff6_4  
vs2015_runtime            14.16.27012          hf0eaf9b_1  
wcwidth                   0.1.7                    py37_0  
webencodings              0.5.1                    py37_1  
wheel                     0.34.1                   py37_0  
widgetsnbextension        3.5.1                    py37_0  
win_inet_pton             1.1.0                    py37_0  
wincertstore              0.2                      py37_0  
winpty                    0.4.3                         4  
xz                        5.2.4                h2fa13f4_4  
yaml                      0.1.7                hc54c509_2  
zeromq                    4.3.1                h33f27b4_3  
zipp                      0.6.0                      py_0  
zlib                      1.2.11               h62dcd97_3  
zstd                      1.3.7                h508b16e_0  

...When I run the following script with panel serve app.py --show...

import param
import panel as pn


class Dummy(param.Parameterized):
    
    a = param.Number(default=1, bounds=(0, None), step=0.1)
    b = param.Number(default=10, bounds=(0, 20), step=0.5)
    c = param.Number(default=10, bounds=(0, None), step=0.05)
    
    @param.depends("a", "b", watch=True)
    def update_c(self):
        self.c = self.a * self.b

dummy = Dummy()
app = pn.panel(dummy)
app.servable()

...I get the following errors in my browser console (tested both on Chrome and Firefox) after movie the slider for a while. The more I move it, the more errors come in.

browsererror

While it doesn't affect so much this simple script, I believe this is the origin of an error I have in an app I'm developing, where the value of the c widget stops updating.

@philippjfr
Copy link
Member

Thanks for the detailed issue. I suspect this will have to be filed upstream in bokeh.

@mattpap
Copy link
Collaborator

mattpap commented Mar 15, 2020

I can reproduce this in panel, but only under a stress test. Can't reproduce in bokeh at this point. Seeing that panel does some handling of websocket-level protocol, I'm tempted to say that this is a panel issue, but without further debugging this may go either way.

@mattpap mattpap added the type: bug Something isn't correct or isn't working label Mar 15, 2020
@philippjfr
Copy link
Member

Can no longer reproduce this with bokeh 2.0 and Panel 0.9.1. Any chance you could give those versions a go and try again?

@mattpap
Copy link
Collaborator

mattpap commented Mar 19, 2020

Can't reproduce either anymore.

@philippjfr
Copy link
Member

Closing then, please reopen if this can be reproduced.

@maximlt
Copy link
Member Author

maximlt commented Mar 20, 2020

I can reproduce it unfortunately.

panel_js_error

I don't know if it's what you'd call a stress test, the GIF displays the real speed. Notice that the stepof b is 0.5. With a lower step value (e.g. 0.005), JS errors would be more frequent.

I created the env with conda install -n test_env -c conda-forge panel:

# packages in environment at C:\Users\maxim\Miniconda3\envs\test_panel:
#
# Name                    Version                   Build  Channel
bokeh                     2.0.0            py38h32f6830_0    conda-forge
ca-certificates           2019.11.28           hecc5488_0    conda-forge
certifi                   2019.11.28       py38h32f6830_1    conda-forge
cffi                      1.14.0           py38ha419a9e_0    conda-forge
chardet                   3.0.4           py38h32f6830_1006    conda-forge
cryptography              2.8              py38hb32ad35_1    conda-forge
freetype                  2.10.1               ha9979f8_0    conda-forge
idna                      2.9                        py_1    conda-forge
intel-openmp              2020.0                      166  
jinja2                    2.11.1                     py_0    conda-forge
jpeg                      9c                hfa6e2cd_1001    conda-forge
libblas                   3.8.0                    15_mkl    conda-forge
libcblas                  3.8.0                    15_mkl    conda-forge
liblapack                 3.8.0                    15_mkl    conda-forge
libpng                    1.6.37               hfe6a214_1    conda-forge
libtiff                   4.1.0                h885aae3_5    conda-forge
lz4-c                     1.8.3             he025d50_1001    conda-forge
markdown                  3.2.1                      py_0    conda-forge
markupsafe                1.1.1            py38h9de7a3e_1    conda-forge
mkl                       2020.0                      166  
numpy                     1.18.1           py38hc71023c_0    conda-forge
olefile                   0.46                       py_0    conda-forge
openssl                   1.1.1e               hfa6e2cd_0    conda-forge
packaging                 20.1                       py_0    conda-forge
panel                     0.9.1                      py_0    conda-forge
param                     1.9.3                      py_0    conda-forge
pillow                    7.0.0            py38h8103267_1    conda-forge
pip                       20.0.2                     py_2    conda-forge
pycparser                 2.20                       py_0    conda-forge
pyct                      0.4.6                      py_0    conda-forge
pyct-core                 0.4.6                      py_0    conda-forge
pyopenssl                 19.1.0                     py_1    conda-forge
pyparsing                 2.4.6                      py_0    conda-forge
pysocks                   1.7.1            py38h32f6830_1    conda-forge
python                    3.8.2           h5fd99cc_4_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.8                      1_cp38    conda-forge
pyviz_comms               0.7.4              pyh8c360ce_0    conda-forge
pyyaml                    5.3.1            py38h9de7a3e_0    conda-forge
requests                  2.23.0             pyh8c360ce_2    conda-forge
setuptools                46.0.0           py38h32f6830_2    conda-forge
six                       1.14.0                     py_1    conda-forge
sqlite                    3.30.1               hfa6e2cd_0    conda-forge
tk                        8.6.10               hfa6e2cd_0    conda-forge
tornado                   6.0.4            py38hfa6e2cd_0    conda-forge
tqdm                      4.43.0                     py_0    conda-forge
typing_extensions         3.7.4.1          py38h32f6830_1    conda-forge
urllib3                   1.25.7           py38h32f6830_1    conda-forge
vc                        14.1                 h0510ff6_4  
vs2015_runtime            14.16.27012          hf0eaf9b_1  
wheel                     0.34.2                     py_1    conda-forge
win_inet_pton             1.1.0                    py38_0    conda-forge
wincertstore              0.2                   py38_1003    conda-forge
xz                        5.2.4             h2fa13f4_1001    conda-forge
yaml                      0.2.2                hfa6e2cd_1    conda-forge
zlib                      1.2.11            h2fa13f4_1006    conda-forge
zstd                      1.4.4                hd8a0e53_2    conda-forge

To reproduce these errors, I ran the following script with panel serve test_panel.py --show --log-level=debug.

import param
import panel as pn


class Dummy(param.Parameterized):
    
    a = param.Number(default=1, bounds=(0, None), step=0.1)
    b = param.Number(default=10, bounds=(0, 20), step=0.5)
    c = param.Number(default=10, bounds=(0, None), step=0.05)
    
    @param.depends("a", "b", watch=True)
    def update_c(self):
        self.c = self.a * self.b

dummy = Dummy()
app = pn.panel(dummy)
app.servable()

@philippjfr philippjfr reopened this Mar 20, 2020
@mattpap
Copy link
Collaborator

mattpap commented Mar 20, 2020

I tested a bokeh variant of this code yesterday. Testing the right code I can confirm the issue is still present.

@philippjfr
Copy link
Member

Strangely enough I still can't reproduce, even if I lower the step. Can't explain it yet.

@philippjfr
Copy link
Member

Okay, I had an older version of tornado, upgrading to 6.0.4 let's me reproduce it.

@philippjfr
Copy link
Member

philippjfr commented Mar 20, 2020

Okay, the issue is that we are working around the asynchronous nature of the server. This is to allow synchronous functions to trigger updates on the frontend immediately instead of blocking until they finish, e.g.:

import panel as pn
import time

button = pn.widgets.Button(name='Run')
progress = pn.widgets.Progress(value=0)

def update_progress(event):
    for i in range(100):
        time.sleep(0.01)
        progress.value = i

button.on_click(update_progress)

pn.Row(button, progress).show()

If we didn't this example wouldn't update the progress bar until the callback finishes. However in implementing this we are not respecting the Websocket handlers write lock. I'll have to see if there's a good solution here. In the longer run we should certainly recommend an async approach to this but I'll see if there's a more short term fix I can make. In the worst case I could revert to locking as soon as a write lock is encountered, which would probably work for most computations where updates aren't triggered in very quick succession.

@philippjfr
Copy link
Member

I pushed my suggested fix up, it's really a bit of a hack but I think it's acceptable until we handle async functions properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants