-
-
Notifications
You must be signed in to change notification settings - Fork 396
General Fixes for Comms #126
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
Conversation
ipykernel/ipkernel.py
Outdated
|
|
||
| self.comm_manager = CommManager(shell=self.shell, parent=self, | ||
| kernel=self) | ||
| self.comm_manager = CommManager(kernel=self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still pass parent=self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, what's the reason for needing parent set?
If it's required, we should just remove the kernel arg and use parent internally then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent passes config. Both parent and kernel should be passed, because it is not required for parent to be the kernel, only a Configurable.
|
Thanks, @dwillmer! |
|
Thanks @minrk |
|
This breaks widgets. (Comm messages from the front end don't get handled). Should we revert it? |
This reverts part of 91c61ac (from ipython#126), which introduced a logic bug which broke handling comm messages, widgets, etc. The logic in the refactoring was complicated enough that the invalid-checking function returned the opposite of what it should have returned. Since the original code in each function was only about 10 lines, I think it’s more complicated to introduce three new undocumented functions instead of just repeating similar logic twice.
This reverts part of 91c61ac (from ipython#126), which introduced a logic bug which broke handling comm messages, widgets, etc. The logic in the refactoring was complicated enough that the invalid-checking function returned the opposite of what it should have returned. Since the original code in each function was only about 10 lines, I think it’s more complicated to introduce three new undocumented functions instead of just repeating similar logic twice. Fixes ipython#137.
Howdy,
This is a general fix-up across the Comm and CommManager classes - there was quite a lot of redundant/duplicate code which has been cleaned up. There’s also a few performance items here - eg. multiple identical dict lookups in the same function.
I deliberately haven’t made whitespace changes, but the editor has auto-cleaned up some trailing whitespace.
The biggest changes (which need input from @minrk @takluyver) are the removal of
sessionandiopub_socketfrom Comm and CommManager. The tests pass and i can't find any places where these items are used directly, but it could do with some thought from you.Their use on CommManager was only to be passed into the Comm objects (which happened in 2 places), and their use on Comm objects is restricted to a single method, so it's simpler to just take them from the kernel object that needs passing down the hierarchy anyway.
ipykernel/comm/manager.py
diktargument wasn’t used. This would have caused a runtime exception had the code ever been hit. Have replaced the single use with a direct check of the logging level, which is more obviously correct to readers.# call, because we store weak refs. The item wasn’t called, and it’s not storing weak refs.kernel.Overall these changes reduce the line count by about 20%, whilst also making the code more efficient, and easier to understand (i.e., smaller methods).
ipykernel/comm/comm.py
shelltrait, because it’s only used in one method (and only then if a message callback is set), and there’s no need for the comm objects to know about it when that method can pull it off ofkernel.iopubfor the same reason asshellabove.sessionfor the same reason.ipykernel/ipykernel.py
shellandparentargs from being passed into CommManager.