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

Tour not working on Windows 10 #397

Closed
letsfigureout opened this issue Dec 16, 2020 · 7 comments · Fixed by #429
Closed

Tour not working on Windows 10 #397

letsfigureout opened this issue Dec 16, 2020 · 7 comments · Fixed by #429
Assignees
Labels
bug Bug in code py Related to Python Driver
Milestone

Comments

@letsfigureout
Copy link

Wave SDK Version, OS

0.10.0, Windows 10, Python 3.7.8

Actual behavior

When I try and run the tour, I get a NotImplementedError message in the console. The webapp fails to load also giving me the same error as in the console.

Expected behavior

I expected the tour to run

Steps To Reproduce

  1. Created a new virtual environment (virtualenv)
  2. Extracted the wave tarball
  3. Activate the newly created virtualenv and install dependencies (pip install -r examples\requirements.txt)
  4. Start waved
  5. Run the tour using "wave run --no-reload examples.tour"
(.venv) C:\code\python\h2oai\wave-0.10.0-windows-amd64>wave run --no-reload examples.tour
----------------------------------------
 Welcome to the H2O Wave Interactive Tour!

 Go to http://localhost:10101/tour        
----------------------------------------  
INFO:     Started server process [22080]  
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:51930 - "POST / HTTP/1.1" 200 OK
Unhandled exception
Traceback (most recent call last):
  File "c:\code\python\h2oai\wave-0.10.0-windows-amd64\.venv\lib\site-packages\h2o_wave\server.py", line 265, in _process
    await self._handle(q)
  File ".\examples\tour.py", line 197, in serve
    await show_example(q, catalog[route])
  File ".\examples\tour.py", line 166, in show_example
    await active_example.start()
  File ".\examples\tour.py", line 48, in start
    sys.executable, os.path.join(example_dir, self.filename)
  File "C:\Python\Python37\Lib\asyncio\subprocess.py", line 217, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "C:\Python\Python37\Lib\asyncio\base_events.py", line 1544, in subprocess_exec
    bufsize, **kwargs)
  File "C:\Python\Python37\Lib\asyncio\base_events.py", line 462, in _make_subprocess_transport
    raise NotImplementedError
NotImplementedError

I did find these posts relating to asyncio and creating a sub-process in windows but I the suggestion there didn't work.

https://stackoverflow.com/questions/45699932/asyncio-stdout-failing
https://docs.python.org/3/library/asyncio-subprocess.html#windows-event-loop

@letsfigureout letsfigureout added the bug Bug in code label Dec 16, 2020
@lo5 lo5 added this to the 0.11 milestone Dec 17, 2020
@lo5 lo5 added the py Related to Python Driver label Dec 17, 2020
@shaz13
Copy link

shaz13 commented Dec 18, 2020

++ wave run examples.tour is not working on Windows 10

@srini-x
Copy link
Contributor

srini-x commented Dec 18, 2020

https://docs.python.org/3.7/library/asyncio-platforms.html#subprocess-support-on-windows

SelectorEventLoop on Windows does not support subproceses. On Windows, ProactorEventLoop should be used instead:

import asyncio

asyncio.set_event_loop_policy(
    asyncio.WindowsProactorEventLoopPolicy())

asyncio.run(your_code())

@srini-x
Copy link
Contributor

srini-x commented Dec 19, 2020

I made it work on my windows machine by doing the following. looks like a uvicorn issue.

when we do wave run the main event loop is created by uvicorn.
so, adding

asyncio.set_event_loop_policy(
    asyncio.WindowsProactorEventLoopPolicy())

to https://github.com/encode/uvicorn/blob/master/uvicorn/loops/asyncio.py fixed the issue reported above.

but I got another error

Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python

based on the advice from here: appveyor/ci#1995 (comment)

I made the following changes to tour.py at line 36

env = dict(
    SYSTEMROOT=os.environ.get('SYSTEMROOT'),
    H2O_WAVE_EXTERNAL_ADDRESS=f'http://{_app_host}:{_app_port}'
)
self.process = await asyncio.create_subprocess_exec(
    sys.executable, '-m', 'uvicorn', '--port', _app_port, f'examples.{self.name}:main', env=env,
)

and it all worked.

@VijithaEkanayake-zz VijithaEkanayake-zz self-assigned this Dec 19, 2020
@MarcSkovMadsen
Copy link

I experienced this issue as well

@lo5 lo5 added the critical label Dec 20, 2020
@lo5
Copy link
Member

lo5 commented Dec 21, 2020

Thank you for reporting - we have a solution; currently testing.

VijithaEkanayake-zz pushed a commit that referenced this issue Dec 21, 2020
Windows does not support SelectorEventLoop. To support tour in all the platforms, replaced asyncio.create_subprocess_exec() with python subprocess. Fixes: #397
VijithaEkanayake-zz pushed a commit that referenced this issue Dec 21, 2020
Windows does not support SelectorEventLoop. To support tour in all the platforms, replaced asyncio.create_subprocess_exec() with python subprocess. Fixes: #397
VijithaEkanayake-zz pushed a commit that referenced this issue Dec 21, 2020
Windows does not support SelectorEventLoop. To support tour in all the platforms, replaced asyncio.create_subprocess_exec() with python subprocess. Fixes: #397
@lo5 lo5 closed this as completed in #429 Dec 22, 2020
lo5 pushed a commit that referenced this issue Dec 22, 2020
…our (#429)

* Replace asyncio.create_subprocess_exec() with python subprocess for tour

Windows does not support SelectorEventLoop. To support tour in all the platforms, replaced asyncio.create_subprocess_exec() with python subprocess. Fixes: #397

* Introduce review suggestions

* Introduce local variable to hold the reference to env

* Introduce local variable to hold the reference to env
@lo5
Copy link
Member

lo5 commented Dec 22, 2020

Thanks for your patience!

You should be able to get the tour working on Windows by replacing your examples\tour.py with this corrected file:
https://github.com/h2oai/wave/blob/master/py/examples/tour.py

We'll push this out in the next release.

@letsfigureout
Copy link
Author

Thanks! Confirmed it now works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in code py Related to Python Driver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants