panel icon indicating copy to clipboard operation
panel copied to clipboard

WSL: Invalid Windows `start` command to open browser when showing a servable from running `asyncio` coroutine.

Open emcd opened this issue 1 year ago • 2 comments

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)

$ uname -r
5.15.133.1-microsoft-standard-WSL2
$ hatch run python -V
Python 3.10.14
$ hatch run pip freeze | grep -E '^(bokeh|panel|param|tornado)'
bokeh==3.4.3
panel==1.4.5
param==2.1.1
tornado==6.4.1

Description of expected behavior and the observed behavior

Expected behavior (which is seen from inside synchronous function but not coroutine):

$ hatch run python panel-asyncio-bug.py
Launching server at http://localhost:34375
405 HEAD / (127.0.0.1) 0.41ms

image

Observed behavior (which is seen from inside of coroutine):

$ hatch run python panel-asyncio-bug.py
Launching server at http://localhost:41805
Start : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:125
+ ... [System.Text.Encoding]::GetEncoding(); Start "http\localhost41805\"
+                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

Complete, minimal, self-contained example code that reproduces the issue

from asyncio import run
from panel.widgets import Button

async def setup( ): pass

def main( ):
    run( setup( ) )
    Button( name = 'foo' ).show( )

async def main_async( ):
    await setup( )
    Button( name = 'foo' ).show( )

#main( )                # Works.
run( main_async( ) )    # Broken.
  • [x] I may be interested in making a pull request to address this (but don't count on it)

emcd avatar Aug 03 '24 21:08 emcd

Maybe the server is dying for another reason and the invalid command is a red herring. However, my understanding is that Tornado 6 is asyncio-based and that Panel/Bokeh use the current event loop. I forced the logging configuration to level logging.DEBUG but do not see anything that indicates a failure of the server. On the surface, it would seem to be playing nicely with the existing event loop.

emcd avatar Aug 03 '24 21:08 emcd

Tried the reproducer in a native Linux environment and it seems that the server is dying silently. The browser tab will actually open without problem but it points to empty content. image

emcd avatar Aug 04 '24 09:08 emcd