mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 14:33:00 +00:00
Merge pull request #1642 from minrk/tornado-5-b
Fixes for tests with tornado 5
This commit is contained in:
@@ -31,7 +31,6 @@ from tornado.log import app_log, access_log, gen_log
|
|||||||
import tornado.options
|
import tornado.options
|
||||||
from tornado import gen, web
|
from tornado import gen, web
|
||||||
from tornado.platform.asyncio import AsyncIOMainLoop
|
from tornado.platform.asyncio import AsyncIOMainLoop
|
||||||
AsyncIOMainLoop().install()
|
|
||||||
|
|
||||||
from traitlets import (
|
from traitlets import (
|
||||||
Unicode, Integer, Dict, TraitError, List, Bool, Any,
|
Unicode, Integer, Dict, TraitError, List, Bool, Any,
|
||||||
@@ -1643,6 +1642,7 @@ class JupyterHub(Application):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def launch_instance(cls, argv=None):
|
def launch_instance(cls, argv=None):
|
||||||
self = cls.instance()
|
self = cls.instance()
|
||||||
|
AsyncIOMainLoop().install()
|
||||||
loop = IOLoop.current()
|
loop = IOLoop.current()
|
||||||
loop.add_callback(self.launch_instance_async, argv)
|
loop.add_callback(self.launch_instance_async, argv)
|
||||||
try:
|
try:
|
||||||
|
@@ -45,9 +45,7 @@ def io_loop(request):
|
|||||||
|
|
||||||
def _close():
|
def _close():
|
||||||
io_loop.clear_current()
|
io_loop.clear_current()
|
||||||
if (not ioloop.IOLoop.initialized() or
|
io_loop.close(all_fds=True)
|
||||||
io_loop is not ioloop.IOLoop.instance()):
|
|
||||||
io_loop.close(all_fds=True)
|
|
||||||
|
|
||||||
request.addfinalizer(_close)
|
request.addfinalizer(_close)
|
||||||
return io_loop
|
return io_loop
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
"""mock utilities for testing"""
|
"""mock utilities for testing"""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -235,6 +236,7 @@ class MockHub(JupyterHub):
|
|||||||
# to avoid multiple eventloops in the same thread errors from asyncio
|
# to avoid multiple eventloops in the same thread errors from asyncio
|
||||||
|
|
||||||
def cleanup():
|
def cleanup():
|
||||||
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||||
loop = IOLoop.current()
|
loop = IOLoop.current()
|
||||||
loop.run_sync(self.cleanup)
|
loop.run_sync(self.cleanup)
|
||||||
loop.close()
|
loop.close()
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
@@ -125,6 +126,7 @@ def test_hub_authenticated(request):
|
|||||||
port = 50505
|
port = 50505
|
||||||
q = Queue()
|
q = Queue()
|
||||||
def run():
|
def run():
|
||||||
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||||
app = Application([
|
app = Application([
|
||||||
('/*', TestHandler),
|
('/*', TestHandler),
|
||||||
], login_url=auth.login_url)
|
], login_url=auth.login_url)
|
||||||
|
Reference in New Issue
Block a user