Repository: bokeh/bokeh

Issue:
[BUG] Blank error message when starting Bokeh server with Python 3.8 on Windows
There seems to be some error with the Windows build of Bokeh for Python 3.8. This is the default environment when building from conda-forge:

OS: Windows 10 Enterprise 1709 16299.1508
Browser: Google Chrome Version 78.0.3904.108 (Official Build) (64-bit)
Python 3.8.0
Bokeh: 1.4.0


```
(base) C:\Users\sdc50\Desktop>conda create -n bokeh-forge -c conda-forge bokeh
...
(base) C:\Users\sdc50\Desktop>conda activate bokeh-forge
(bokeh-forge) C:\Users\sdc50\Desktop>python -V
Python 3.8.0
(bokeh-forge) C:\Users\sdc50\Desktop>bokeh serve sliders.py
2019-12-05 12:24:59,418 Starting Bokeh server version 1.4.0 (running on Tornado 6.0.3)
2019-12-05 12:24:59,450 User authentication hooks NOT provided (default user enabled)
ERROR:
(bokeh-forge) C:\Users\sdc50\Desktop>
```

Compare to:
```
(base) C:\Users\sdc50\Desktop>conda create -n bokeh-defaults bokeh
...
(base) C:\Users\sdc50\Desktop>conda activate bokeh-defaults

(bokeh-defaults) C:\Users\sdc50\Desktop>python -V
Python 3.7.5
(bokeh-defaults) C:\Users\sdc50\Desktop>bokeh serve sliders.py
2019-12-05 12:05:27,758 Starting Bokeh server version 1.4.0 (running on Tornado 6.0.3)
2019-12-05 12:05:27,764 User authentication hooks NOT provided (default user enabled)
2019-12-05 12:05:27,767 Bokeh app running at: http://localhost:5006/sliders
2019-12-05 12:05:27,767 Starting Bokeh server with process id: 29900
2019-12-05 12:05:46,601 WebSocket connection opened
2019-12-05 12:05:46,603 ServerConnection created

Interrupted, shutting down

(bokeh-defaults) C:\Users\sdc50\Desktop>

```

Also compare to:
```
(base) C:\Users\sdc50\Desktop>conda create -n bokeh-forge-py37 -c conda-forge python=3.7 bokeh
...
(base) C:\Users\sdc50\Desktop>conda activate bokeh-forge-py37
(bokeh-forge) C:\Users\sdc50\Desktop>conda activate bokeh-forge-py37

(bokeh-forge-py37) C:\Users\sdc50\Desktop>python -V
Python 3.7.3

(bokeh-forge-py37) C:\Users\sdc50\Desktop>bokeh serve sliders.py
2019-12-05 12:39:20,424 Starting Bokeh server version 1.4.0 (running on Tornado 6.0.3)
2019-12-05 12:39:20,430 User authentication hooks NOT provided (default user enabled)
2019-12-05 12:39:20,434 Bokeh app running at: http://localhost:5006/sliders
2019-12-05 12:39:20,434 Starting Bokeh server with process id: 27996
2019-12-05 12:39:27,108 WebSocket connection opened
2019-12-05 12:39:27,109 ServerConnection created

Interrupted, shutting down

(bokeh-forge-py37) C:\Users\sdc50\Desktop>

```

It looks like there isn't a build for py38 on defaults, so it cannot be used to compare against.



Discussion:
Bokeh isn't supported officially on 3.8 yet (see PR #9344). Can you try out `master` or the latest 2.0 dev builds (available on `bokeh/dev` channel)? There were plenty of changes since 1.4, that could change this behavior.
Right, we are still waiting on missing package availability to be able to start up our CI testing on Python 3.8. We definitely won't be able to go back an fix anything for 1.x as the repo has moved on. So as @mattpap suggest the best next step is to try a 2.0 dev build with Python 3.8. You can conda install a dev build with:

    conda install -c bokeh/c/dev bokeh 

I'll certainly try as well but others can probably get to it before me

Another question: is it just this auth hooks example ? Or does any bokeh server app have problems with 3.8 on windows?
> Can you try out `master` or the latest 2.0 dev builds

Yes, I'll give it a try with the 2.0 dev builds. Getting access to a Windows VM is a bit clunky for me, so I'm not sure when I'll be able to get to it. I should note that I am running Bokeh 1.4 with Python 3.8 on my MacOS and everything seems to be working fine there.

> Another question: is it just this auth hooks example ? Or does any bokeh server app have problems with 3.8 on windows?

We actually tested this with the basic `sliders.py` example (not the one with the auth hooks). But we also were getting the same behavior with our custom code, so I assume it will fail for all examples. 

@ocefpaf is it possible to flag the `win-64/bokeh-1.4.0-py38_0.tar.bz2` build on conda-forge as broken? It would be nice to not have this broken version install be default when the Python version is not pinned.
Done. Please check https://anaconda.org/conda-forge/bokeh/files?version=1.4.0 to see if I got it right.

PS: in the future please add an issue in the feedstock and ping `@conda-forge/core`, the former is so we can track these labels requests and the latter is b/c I'm not always available.
@ocefpaf Thanks!

> PS: in the future please add an issue in the feedstock and ping `@conda-forge/core`, the former is so we can track these labels requests and the latter is b/c I'm not always available.

Roger that!
> Can you try out `master` or the latest 2.0 dev builds (available on `bokeh/dev` channel)

It looks like it has the same behavior with 2.0.0dev5:
```
(base) C:\Users\sdc50>conda create -c bokeh/label/dev -n bokeh2 bokeh 
...
(base) C:\Users\sdc50>conda activate bokeh2
(bokeh2) C:\Users\sdc50>bokeh serve sliders.py
2019-12-06 11:02:49,294 Starting Bokeh server version 2.0.0dev5 (running on Tornado 6.0.3)
2019-12-06 11:02:49,302 User authentication hooks NOT provided (default user enabled)
ERROR:

(bokeh2) C:\Users\sdc50>conda deactivate
```

> Another question: is it just this auth hooks example ? Or does any bokeh server app have problems with 3.8 on windows?

I just tried running several of the examples from the repo and all had the same behavior.
OK I think this possibly points to being purely a python 3.8 issue (at least on windows if not others)

Resolving patch:
diff --git a/bokeh/server/tornado.py b/bokeh/server/tornado.py
--- a/bokeh/server/tornado.py
+++ b/bokeh/server/tornado.py
@@ -20,6 +20,7 @@
 
 # Standard library imports
 import os
+import sys
 from pprint import pformat
 from urllib.parse import urljoin
 
@@ -598,3 +599,8 @@ def _keep_alive(self):
     DEFAULT_UNUSED_LIFETIME_MS=DEFAULT_UNUSED_LIFETIME_MS,
     DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES=DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES,
 )
+
+# See https://github.com/bokeh/bokeh/issues/9507
+if sys.platform == 'win32' and sys.version_info[:3] >= (3, 8, 0):
+    import asyncio
+    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())


Test patch: