##// END OF EJS Templates
Don't wait forever for notebook server to launch/die for tests...
Thomas Kluyver -
Show More
@@ -24,19 +24,24 b' class NotebookTestBase(TestCase):'
24 def wait_until_alive(cls):
24 def wait_until_alive(cls):
25 """Wait for the server to be alive"""
25 """Wait for the server to be alive"""
26 url = 'http://localhost:%i/api/notebooks' % cls.port
26 url = 'http://localhost:%i/api/notebooks' % cls.port
27 while True:
27 for _ in range(300):
28 try:
28 try:
29 requests.get(url)
29 requests.get(url)
30 except requests.exceptions.ConnectionError:
30 except requests.exceptions.ConnectionError:
31 if cls.notebook.poll() is not None:
32 raise RuntimeError("The notebook server exited with status %s" \
33 % cls.notebook.poll())
31 time.sleep(.1)
34 time.sleep(.1)
32 else:
35 else:
33 break
36 return
37
38 raise TimeoutError("The notebook server didn't start up correctly.")
34
39
35 @classmethod
40 @classmethod
36 def wait_until_dead(cls):
41 def wait_until_dead(cls):
37 """Wait for the server to stop getting requests after shutdown"""
42 """Wait for the server to stop getting requests after shutdown"""
38 url = 'http://localhost:%i/api/notebooks' % cls.port
43 url = 'http://localhost:%i/api/notebooks' % cls.port
39 while True:
44 for _ in range(300):
40 try:
45 try:
41 requests.get(url)
46 requests.get(url)
42 except requests.exceptions.ConnectionError:
47 except requests.exceptions.ConnectionError:
@@ -44,6 +49,8 b' class NotebookTestBase(TestCase):'
44 else:
49 else:
45 time.sleep(.1)
50 time.sleep(.1)
46
51
52 raise TimeoutError("Undead notebook server")
53
47 @classmethod
54 @classmethod
48 def setup_class(cls):
55 def setup_class(cls):
49 cls.ipython_dir = TemporaryDirectory()
56 cls.ipython_dir = TemporaryDirectory()
@@ -52,6 +59,7 b' class NotebookTestBase(TestCase):'
52 sys.executable, '-c',
59 sys.executable, '-c',
53 'from IPython.html.notebookapp import launch_new_instance; launch_new_instance()',
60 'from IPython.html.notebookapp import launch_new_instance; launch_new_instance()',
54 '--port=%d' % cls.port,
61 '--port=%d' % cls.port,
62 '--port-retries=0',
55 '--no-browser',
63 '--no-browser',
56 '--ipython-dir=%s' % cls.ipython_dir.name,
64 '--ipython-dir=%s' % cls.ipython_dir.name,
57 '--notebook-dir=%s' % cls.notebook_dir.name,
65 '--notebook-dir=%s' % cls.notebook_dir.name,
General Comments 0
You need to be logged in to leave comments. Login now