Skip to content

Commit fc2dc8f

Browse files
authored
Merge pull request #4785 from dleen/master
Prevent tests from hanging
2 parents 2eb5544 + fd4275c commit fc2dc8f

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

notebook/tests/launchnotebook.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -140,35 +140,35 @@ def tmp(*parts):
140140

141141
started = Event()
142142
def start_thread():
143-
app = cls.notebook = NotebookApp(
144-
port=cls.port,
145-
port_retries=0,
146-
open_browser=False,
147-
config_dir=cls.config_dir,
148-
data_dir=cls.data_dir,
149-
runtime_dir=cls.runtime_dir,
150-
notebook_dir=cls.notebook_dir,
151-
base_url=cls.url_prefix,
152-
config=config,
153-
allow_root=True,
154-
token=cls.token,
155-
)
156-
if 'asyncio' in sys.modules:
157-
app._init_asyncio_patch()
158-
import asyncio
159-
asyncio.set_event_loop(asyncio.new_event_loop())
160-
# don't register signal handler during tests
161-
app.init_signal = lambda : None
162-
# clear log handlers and propagate to root for nose to capture it
163-
# needs to be redone after initialize, which reconfigures logging
164-
app.log.propagate = True
165-
app.log.handlers = []
166-
app.initialize(argv=cls.get_argv())
167-
app.log.propagate = True
168-
app.log.handlers = []
169-
loop = IOLoop.current()
170-
loop.add_callback(started.set)
171143
try:
144+
app = cls.notebook = NotebookApp(
145+
port=cls.port,
146+
port_retries=0,
147+
open_browser=False,
148+
config_dir=cls.config_dir,
149+
data_dir=cls.data_dir,
150+
runtime_dir=cls.runtime_dir,
151+
notebook_dir=cls.notebook_dir,
152+
base_url=cls.url_prefix,
153+
config=config,
154+
allow_root=True,
155+
token=cls.token,
156+
)
157+
if 'asyncio' in sys.modules:
158+
app._init_asyncio_patch()
159+
import asyncio
160+
asyncio.set_event_loop(asyncio.new_event_loop())
161+
# don't register signal handler during tests
162+
app.init_signal = lambda : None
163+
# clear log handlers and propagate to root for nose to capture it
164+
# needs to be redone after initialize, which reconfigures logging
165+
app.log.propagate = True
166+
app.log.handlers = []
167+
app.initialize(argv=cls.get_argv())
168+
app.log.propagate = True
169+
app.log.handlers = []
170+
loop = IOLoop.current()
171+
loop.add_callback(started.set)
172172
app.start()
173173
finally:
174174
# set the event, so failure to start doesn't cause a hang

0 commit comments

Comments
 (0)