Merge pull request #1642 from minrk/tornado-5-b

Fixes for tests with tornado 5
This commit is contained in:
Min RK
2018-02-01 19:57:59 +01:00
committed by GitHub
4 changed files with 6 additions and 4 deletions

View File

@@ -31,7 +31,6 @@ from tornado.log import app_log, access_log, gen_log
import tornado.options
from tornado import gen, web
from tornado.platform.asyncio import AsyncIOMainLoop
AsyncIOMainLoop().install()
from traitlets import (
Unicode, Integer, Dict, TraitError, List, Bool, Any,
@@ -1643,6 +1642,7 @@ class JupyterHub(Application):
@classmethod
def launch_instance(cls, argv=None):
self = cls.instance()
AsyncIOMainLoop().install()
loop = IOLoop.current()
loop.add_callback(self.launch_instance_async, argv)
try:

View File

@@ -45,8 +45,6 @@ def io_loop(request):
def _close():
io_loop.clear_current()
if (not ioloop.IOLoop.initialized() or
io_loop is not ioloop.IOLoop.instance()):
io_loop.close(all_fds=True)
request.addfinalizer(_close)

View File

@@ -1,5 +1,6 @@
"""mock utilities for testing"""
import asyncio
from concurrent.futures import ThreadPoolExecutor
import os
import sys
@@ -235,6 +236,7 @@ class MockHub(JupyterHub):
# to avoid multiple eventloops in the same thread errors from asyncio
def cleanup():
asyncio.set_event_loop(asyncio.new_event_loop())
loop = IOLoop.current()
loop.run_sync(self.cleanup)
loop.close()

View File

@@ -1,3 +1,4 @@
import asyncio
from binascii import hexlify
import copy
import json
@@ -125,6 +126,7 @@ def test_hub_authenticated(request):
port = 50505
q = Queue()
def run():
asyncio.set_event_loop(asyncio.new_event_loop())
app = Application([
('/*', TestHandler),
], login_url=auth.login_url)