Skip to content

Commit

Permalink
call metadata methods on abort replies
Browse files Browse the repository at this point in the history
ensures aborted messages have consistent metadata with real replies
  • Loading branch information
minrk committed Jun 7, 2021
1 parent fda1156 commit 0a22670
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ async def dispatch_shell(self, msg):
self.log.error("Exception in message handler:", exc_info=True)
except KeyboardInterrupt:
# Ctrl-c shouldn't crash the kernel here.
self.log.error("KeyboardInterrupt caught in kernel.")
self.log.error("KeyboardInterrupt caught in kernel.")
finally:
try:
self.post_handler_hook()
Expand Down Expand Up @@ -921,12 +921,15 @@ def stop_aborting():

def _send_abort_reply(self, stream, msg, idents):
"""Send a reply to an aborted request"""
self.log.info("Aborting:")
self.log.info("%s", msg)
self.log.info(
f"Aborting {msg['header']['msg_id']}: {msg['header']['msg_type']}"
)
reply_type = msg["header"]["msg_type"].rsplit("_", 1)[0] + "_reply"
status = {"status": "aborted"}
md = {"engine": self.ident}
md = self.init_metadata(msg)
md = self.finish_metadata(msg, md, status)
md.update(status)

self.session.send(
stream, reply_type, metadata=md,
content=status, parent=msg, ident=idents,
Expand Down

0 comments on commit 0a22670

Please sign in to comment.