title: Flask/Bokeh/Tornado6.0.2: Embedded bokeh servers no longer work after Tornado update
body: <p>I have numerous Bokeh Server files in a directory say.. /dir/bokeh/, assume the bokeh servers are called bokeh1.py, bokeh2.py, bokeh3.py
  The file structure is like so:</p>
  
  <pre><code>|--dir
      |---flask.py
      |---bokeh
            |--bokeh1.py
            |--bokeh2.py
  </code></pre>
  
  <p>I am deploying them all on flask like so:</p>
  
  <pre><code>files=[]
  for file in os.listdir("/dir/bokeh/"):
      if file.endswith('.py'):
          file="bokeh/"+file
          files.append(file)
  
  argvs = {}
  urls = []
  for i in files:
      argvs[i] = None
      urls.append(i.split('\\')[-1].split('.')[0])
  host = 'myhost.com'
  
  apps = build_single_handler_applications(files, argvs)
  
  bokeh_tornado = BokehTornado(apps, extra_websocket_origins=["myhost.com"])
  bokeh_http = HTTPServer(bokeh_tornado)
  sockets, port = bind_sockets("myhost.com", 0)
  bokeh_http.add_sockets(sockets)
  </code></pre>
  
  <p>On update to Tornado 6.0.2, and deploying Flask, I get the Runtimerror <code>There is no current event loop in thread Thread-1</code>. On deeper research Tornado uses <code>asyncio</code> by default and imposes some restrictions. So I add <code>asyncio.set_event_loop(asyncio.new_event_loop())</code> to the following.</p>
  
  <pre><code>def bk_worker():
      asyncio.set_event_loop(asyncio.new_event_loop())####
      server = BaseServer(IOLoop.current(), bokeh_tornado, bokeh_http)
      server.start()
      server.io_loop.start()
      gc.collect()
  
  from threading import Thread
  
  Thread(target=bk_worker).start()
  </code></pre>
  
  <p>However, upon opening the bokeh server url through flask, the bokeh server selected (any of them) do not load and simply return a blank page. How can I circumvent this?</p>
  
  <p>setting <code>asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy))</code> yields the same result.</p>
  
  <p>edit:The previous code works with python 2/3, Tornado 4.5.3</p>