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

Fixing #659 (output cutoff and iopub timeout) #994

Merged
merged 16 commits into from May 17, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

add a couple deadline tests

  • Loading branch information
djherbis committed May 2, 2019
commit c08e527a8a7dbe20bdd195db6db966ee1671460e
@@ -7,9 +7,9 @@
from textwrap import dedent
from contextlib import contextmanager
try:
from time import monotonic
from time import monotonic # Py 3
except ImportError:
from time import time as monotonic
from time import time as monotonic # Py 2

try:
from queue import Empty # Py 3
@@ -526,6 +526,7 @@ def run_cell(self, cell, cell_index=0):
parent_msg_id = self.kc.execute(cell.source)
self.log.debug("Executing cell:\n%s", cell.source)
exec_timeout = self._get_timeout(cell)
deadline = None
if exec_timeout is not None:
deadline = monotonic() + exec_timeout

@@ -31,6 +31,10 @@
from testpath import modified_env
from ipython_genutils.py3compat import string_types

try:
from queue import Queue # Py 3
except ImportError:
from Queue import Queue # Py2
try:
TimeoutError # Py 3
except NameError:
@@ -507,6 +511,28 @@ def test_busy_message(self, preprocessor, cell_mock, message_mock):
# Ensure no outputs were generated
assert cell_mock.outputs == []

@ExecuteTestBase.prepare_cell_mocks()
def test_deadline_exec_reply(self, preprocessor, cell_mock, message_mock):
q = Queue()
# Both channels will never receive, so we expect to hit the timeout.
preprocessor.kc.shell_channel.get_msg = lambda timeout=0 : q.get(timeout=timeout)
preprocessor.kc.iopub_channel.get_msg = lambda timeout=0 : q.get(timeout=timeout)
preprocessor.timeout = 1

with pytest.raises(TimeoutError):
preprocessor.run_cell(cell_mock)

@ExecuteTestBase.prepare_cell_mocks()
def test_deadline_iopub(self, preprocessor, cell_mock, message_mock):
q = Queue()
# The shell_channel will complete, so we expect only to hit the iopub timeout.
preprocessor.kc.iopub_channel.get_msg = lambda timeout=0 : q.get(timeout=timeout)
preprocessor.iopub_timeout = 1
preprocessor.raise_on_iopub_timeout = True

with pytest.raises(RuntimeError):
preprocessor.run_cell(cell_mock)

@ExecuteTestBase.prepare_cell_mocks({
'msg_type': 'execute_input',
'header': {'msg_type': 'execute_input'},
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.