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

Remove block param from get_msg() #736

Merged
merged 2 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ipykernel/tests/test_embed_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ def test_embed_kernel_basic():
with setup_kernel(cmd) as client:
# oinfo a (int)
client.inspect("a")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']

client.execute("c=a*2")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['status'] == 'ok'

# oinfo c (should be 10)
client.inspect("c")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
Expand All @@ -129,23 +129,23 @@ def test_embed_kernel_namespace():
with setup_kernel(cmd) as client:
# oinfo a (int)
client.inspect("a")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
assert '5' in text

# oinfo b (str)
client.inspect("b")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
assert 'hi there' in text

# oinfo c (undefined)
client.inspect("c")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert not content['found']

Expand All @@ -168,13 +168,13 @@ def test_embed_kernel_reentrant():
with setup_kernel(cmd) as client:
for i in range(5):
client.inspect("count")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
assert str(i) in text

# exit from embed_kernel
client.execute("get_ipython().exit_now = True")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
time.sleep(0.2)
20 changes: 10 additions & 10 deletions ipykernel/tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ def test_raw_input():
theprompt = "prompt> "
code = 'print({input_f}("{theprompt}"))'.format(**locals())
msg_id = kc.execute(code, allow_stdin=True)
msg = kc.get_stdin_msg(block=True, timeout=TIMEOUT)
msg = kc.get_stdin_msg(timeout=TIMEOUT)
assert msg['header']['msg_type'] == 'input_request'
content = msg['content']
assert content['prompt'] == theprompt
text = "some text"
kc.input(text)
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'ok'
stdout, stderr = assemble_output(kc.get_iopub_msg)
assert stdout == text + "\n"
Expand Down Expand Up @@ -249,22 +249,22 @@ def test_is_complete():
# There are more test cases for this in core - here we just check
# that the kernel exposes the interface correctly.
kc.is_complete('2+2')
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'complete'

# SyntaxError
kc.is_complete('raise = 2')
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'invalid'

kc.is_complete('a = [1,\n2,')
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'incomplete'
assert reply['content']['indent'] == ''

# Cell magic ends on two blank lines for console UIs
kc.is_complete('%%timeit\na\n\n')
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'complete'


Expand All @@ -275,7 +275,7 @@ def test_complete():
wait_for_idle(kc)
cell = 'import IPython\nb = a.'
kc.complete(cell)
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)

c = reply['content']
assert c['status'] == 'ok'
Expand Down Expand Up @@ -341,20 +341,20 @@ def test_unc_paths():
unc_file_path = os.path.join(unc_root, file_path[1:])

kc.execute("cd {0:s}".format(unc_file_path))
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'ok'
out, err = assemble_output(kc.get_iopub_msg)
assert unc_file_path in out

flush_channels(kc)
kc.execute(code="ls")
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'ok'
out, err = assemble_output(kc.get_iopub_msg)
assert 'unc.txt' in out

kc.execute(code="cd")
reply = kc.get_shell_msg(block=True, timeout=TIMEOUT)
reply = kc.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'ok'


Expand Down
10 changes: 5 additions & 5 deletions ipykernel/tests/test_start_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ def test_ipython_start_kernel_userns():

with setup_kernel(cmd) as client:
client.inspect("tre")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
assert '123' in text

# user_module should be an instance of DummyMod
client.execute("usermod = get_ipython().user_module")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg["content"]
assert content["status"] == "ok"
client.inspect("usermod")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
Expand All @@ -40,11 +40,11 @@ def test_ipython_start_kernel_no_userns():
with setup_kernel(cmd) as client:
# user_module should not be an instance of DummyMod
client.execute("usermod = get_ipython().user_module")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg["content"]
assert content["status"] == "ok"
client.inspect("usermod")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
msg = client.get_shell_msg(timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
Expand Down
6 changes: 3 additions & 3 deletions ipykernel/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def flush_channels(kc=None):
for get_msg in (kc.get_shell_msg, kc.get_iopub_msg):
while True:
try:
msg = get_msg(block=True, timeout=0.1)
msg = get_msg(timeout=0.1)
except Empty:
break
else:
Expand Down Expand Up @@ -155,7 +155,7 @@ def assemble_output(get_msg):
stdout = ''
stderr = ''
while True:
msg = get_msg(block=True, timeout=1)
msg = get_msg(timeout=1)
msg_type = msg['msg_type']
content = msg['content']
if msg_type == 'status' and content['execution_state'] == 'idle':
Expand All @@ -175,7 +175,7 @@ def assemble_output(get_msg):

def wait_for_idle(kc):
while True:
msg = kc.get_iopub_msg(block=True, timeout=1)
msg = kc.get_iopub_msg(timeout=1)
msg_type = msg['msg_type']
content = msg['content']
if msg_type == 'status' and content['execution_state'] == 'idle':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def run(self):
'debugpy>=1.0.0,<2.0',
'ipython>=7.23.1,<8.0',
'traitlets>=4.1.0,<6.0',
'jupyter_client<7.0',
'jupyter_client<8.0',
'tornado>=4.2,<7.0',
'matplotlib-inline>=0.1.0,<0.2.0',
'appnope;platform_system=="Darwin"',
Expand Down