Skip to content

Commit

Permalink
feat: let display hook handle clear_output
Browse files Browse the repository at this point in the history
A display hook can handle a publish message, but not yet a clear_output

Upstreaming of: widgetti/solara#132
Follow up of: ipython#1110
Related: https://github.com/ipython/ipykernel/pull/115/files

Would enable jupyter-widgets/ipywidgets#3759
to fully work kernel side.
  • Loading branch information
maartenbreddels committed Jul 20, 2023
1 parent 1abb019 commit e4ede7e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ipykernel/zmqshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,17 @@ def clear_output(self, wait=False):
"""
content = dict(wait=wait)
self._flush_streams()
msg = self.session.msg("clear_output", json_clean(content), parent=self.parent_header)

# see publish() for details on how this works
for hook in self._hooks:
msg = hook(msg)
if msg is None:
return

self.session.send(
self.pub_socket,
"clear_output",
content,
parent=self.parent_header,
msg,
ident=self.topic,
)

Expand Down

0 comments on commit e4ede7e

Please sign in to comment.