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
Conversation
Should turn occasional hangs into straightforward errors.
|
||
@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: | ||
for _ in range(300): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
in general, I'd say it's good practice to avoid having bare naked constants in code like the 300 used twice here without a name or an explanation. If you just add a MAX_WAITTIME = 30 # seconds to wait for notebook server to start
POLL_INTERVAL = 0.1 # time between attempts Then you can changes your for loops to be But since this is just test code, I'm not too bothered by it. |
otherwise 👍 |
@@ -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', |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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"
Thanks for clarifying the code, Paul ;-) |
Don't wait forever for notebook server to launch/die for tests
Don't wait forever for notebook server to launch/die for tests
Should turn occasional test hangs (e.g. https://s3.amazonaws.com/archive.travis-ci.org/jobs/16615179/log.txt ) into straightforward errors.