-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
New hook point for messages / message transforms. #113
Comments
Also, there are issues with threading. Since the ZMQDisplayPublisher is a global object, installing a message filter there naively will affect messages from everywhere. In the case of a context manager, it seems that the "correct" behavior is to only have the output from the block of code in the current thread. @minrk suggested making the hooks thread local attributes in the ZMQDisplayPublisher object (see https://docs.python.org/2/library/threading.html#threading.local), maybe something like from threading import local
class ZMQDisplayPublisher(...):
def __init__(...):
self.threadlocal = local()
def register_hook(self, hook):
if not hasattr(self.threadlocal, 'hooks'):
self.threadlocal.hooks = []
self.threadlocal.hooks.append(hook) |
Code to touch for making a display hook registration system includes the following.
@minrk, can you verify this is right? |
Interestingly, since clear_output is implemented by just sending a clear_output message to the front end, this works too: with output_widget.capture_messages():
clear_output() |
Yup, that should be right. Also to clarify, implementing this hook should need no changes in any other repos, but the intention is to use it in a new implementation of the OutputWidget downstream. |
@dwillmer, @minrk: next steps: We can get a handle on the display publisher with
@minrk - can you remind us what needs to be done for capturing stdout/stderr? |
@jasongrout - is this ^^ what you're expecting? The Clearly we'll change the name from |
Yep, that's the idea. Thanks! Things to still do:
And when I finish the widgets in the new notebook, actually render the messages sent to the message widget. |
Just checking, the hook unregisters itself when the context manager exits, right? (that's not illustrated in your screenshot, but it should work that way) |
yep, it does, i'll post an updated screenshot in a bit. |
For stdout/err, the simple thing is to swap out |
@dwillmer - no need to post a new screenshot for the exit status. I trust it's there. |
We intend to make a new hook point to allow the installation of hooks on the display publisher.
Current thoughts (largely from @minrk + @jasongrout):
send
it in the usual manner.This will require:
The text was updated successfully, but these errors were encountered: