Skip to content

Commit e4ede7e

Browse files
feat: let display hook handle clear_output
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.
1 parent 1abb019 commit e4ede7e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ipykernel/zmqshell.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,17 @@ def clear_output(self, wait=False):
144144
"""
145145
content = dict(wait=wait)
146146
self._flush_streams()
147+
msg = self.session.msg("clear_output", json_clean(content), parent=self.parent_header)
148+
149+
# see publish() for details on how this works
150+
for hook in self._hooks:
151+
msg = hook(msg)
152+
if msg is None:
153+
return
154+
147155
self.session.send(
148156
self.pub_socket,
149-
"clear_output",
150-
content,
151-
parent=self.parent_header,
157+
msg,
152158
ident=self.topic,
153159
)
154160

0 commit comments

Comments
 (0)