Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
garlandz-db committed Mar 1, 2023
1 parent b9225a3 commit 407983d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,10 @@ async def interrupt_request(self, stream, ident, parent):
"""Handle an interrupt request."""
try:
self._send_interrupt_children()
content = { "status": "ok" }
content = {"status": "ok"}
except OSError as err:
import traceback

content = {
"status": "error",
"traceback": traceback.format_stack(),
Expand Down
4 changes: 3 additions & 1 deletion ipykernel/tests/test_ipkernel_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ async def test_comm_info_request(ipkernel):
async def test_direct_interrupt_request(ipkernel):
reply = await ipkernel.test_control_message("interrupt_request", {})
assert reply["header"]["msg_type"] == "interrupt_reply"
assert reply["content"] == { "status": "ok" }
assert reply["content"] == {"status": "ok"}

# test failure on interrupt request
def raiseOSError():
raise OSError("evalue")

ipkernel._send_interrupt_children = raiseOSError
reply = await ipkernel.test_control_message("interrupt_request", {})
assert reply["header"]["msg_type"] == "interrupt_reply"
Expand All @@ -105,6 +106,7 @@ def raiseOSError():
assert reply["content"]["evalue"] == "evalue"
assert len(reply["content"]["traceback"]) > 0


# TODO: this causes deadlock
# async def test_direct_shutdown_request(ipkernel):
# reply = await ipkernel.test_shell_message("shutdown_request", dict(restart=False))
Expand Down
3 changes: 2 additions & 1 deletion ipykernel/tests/test_kernel_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ async def test_comm_info_request(kernel):
async def test_direct_interrupt_request(kernel):
reply = await kernel.test_control_message("interrupt_request", {})
assert reply["header"]["msg_type"] == "interrupt_reply"
assert reply["content"] == { "status": "ok" }
assert reply["content"] == {"status": "ok"}

# test failure on interrupt request
def raiseOSError():
raise OSError("evalue")

kernel._send_interrupt_children = raiseOSError
reply = await kernel.test_control_message("interrupt_request", {})
assert reply["header"]["msg_type"] == "interrupt_reply"
Expand Down

0 comments on commit 407983d

Please sign in to comment.