Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't wait forever for notebook server to launch/die for tests #4773

Merged
merged 3 commits into from Jan 9, 2014
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 15 additions & 11 deletions IPython/html/tests/launchnotebook.py
Expand Up @@ -24,26 +24,29 @@ class NotebookTestBase(TestCase):
def wait_until_alive(cls):
"""Wait for the server to be alive"""
url = 'http://localhost:%i/api/notebooks' % cls.port
while True:
for _ in range(300):
try:
requests.get(url)
except requests.exceptions.ConnectionError:
if cls.notebook.poll() is not None:
raise RuntimeError("The notebook server exited with status %s" \
% cls.notebook.poll())
time.sleep(.1)
else:
break
return

raise TimeoutError("The notebook server didn't start up correctly.")

@classmethod
def wait_until_dead(cls):
"""Wait for the server to stop getting requests after shutdown"""
url = 'http://localhost:%i/api/notebooks' % cls.port
while True:
try:
requests.get(url)
except requests.exceptions.ConnectionError:
break
else:
time.sleep(.1)
"""Wait for the server process to terminate after shutdown"""
for _ in range(300):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one can just wait until notebook.poll() is not None, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I've simplified it now.

if cls.notebook.poll() is not None:
return
time.sleep(.1)

raise TimeoutError("Undead notebook server")

@classmethod
def setup_class(cls):
cls.ipython_dir = TemporaryDirectory()
Expand All @@ -52,6 +55,7 @@ def setup_class(cls):
sys.executable, '-c',
'from IPython.html.notebookapp import launch_new_instance; launch_new_instance()',
'--port=%d' % cls.port,
'--port-retries=0',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this "don't retry" or "retry indefinitely"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first - it is "retry zero times"

'--no-browser',
'--ipython-dir=%s' % cls.ipython_dir.name,
'--notebook-dir=%s' % cls.notebook_dir.name,
Expand Down