Repository navigation
Refactor kernel channel classes - #7108
Conversation
|
As an outsider attempting to muck with IPython occasionally, I have found myself attempting to follow that rats nest a few times. It would be great to see that refined sooner than later. Thanks! |
I would say we have the choice between :
I'll let you pick. |
|
I'll just ping all four, and let them pick ;-) @epatters @rkern @jonathanrocher @jdmarch - this PR involves a substantial refactoring of the 'channel' classes used internally in the Qt console. I hope no code outside IPython is using these classes directly, but if it is, please let us know. Other code working with the KernelClient API may be affected, but it should be fairly straightforward to fix that. |
|
@takluyver thanks for the heads up! |
|
I also agree with @dsblank: this should go in 3.0 rather than later because these are important API changes. I'll give some look to the Qt part next week. |
There was a problem hiding this comment.
Since this is all a channel really does now, it probably makes sense to replace ._queue_send with .send.
|
I've had a read through, and this seems like a solid improvement over the current situation. A refactor like this close to release does make me a bit uneasy, but as has been discussed above, doing it now will be a lot less painful than doing it after the repos separate. Other than a minor pyzmq style point above, I'm 👍 to all this. |
|
Addressed Min's comments. |
+1 then. |
|
I've looked it over, and it all seems to make sense to me. I'll wait for @ccordoba12 to do a sanity check on the Qt parts, then I'd say it's okay to merge. |
|
These are nice clean ups, but I wonder this will affect third-party console clients that want to communniucate with a ZMQ kernel asyncronously? The following is probably not The Right Way To Do It, but in a client for IPython 2.x (an experimental plugin for Neovim) I do the following to recieve async notifications for messages: (where the target, running inside a different event loop, is aware notifications come from a different thread). Now how will this the simplest be done on the new infrastructure? To me it seems the new QtKernelClient and its helper classes does almost what another async console client wants (or at least mine); I mean very few parts of it are Qt specific. Do you think it would make sense to later refactor this into a generic async/thread-safe zmqsocketchannel/kernelclient (and perhaps implement the Qt kernel client on top of it)? |
|
Thanks @bfredl for that use case. Yes, it may well at some point make sense to split out a base class for a generic async client. I'd rather not do that here, because it's a big enough PR already, and since we only have one asynchronous client (the Qt console), I probably wouldn't get the abstractions right. There are really two possibilities for async clients:
|
|
@takluyver Yes, ideally, a base client class could be able to either provide a list of ZMQ fds (and callbacks for each) to the client developer to plug in to a event loop framwork of their choosing, or spawn a thread if preferred, but it probably requires some work to be thread-safe in all cases and have suitable abstractions. |
|
Thanks for waiting for me @minrk and @takluyver. I'll do my review tomorrow, I was just fixing some breakage I introduced in Spyder yesterday :-) |
|
@ccordoba12 No worries, thanks for reviewing! |
|
I ran our test suite against this on Windows, and it passed on Python 3.4 and Python 2.7. |
There was a problem hiding this comment.
These make_*_socket functions doesn't seem to be used in this file. Are they really necessary?
There was a problem hiding this comment.
Spoke to Min, and they are redundant with some methods on ConnectionFileMixin. Removing, thanks.
|
Other than the little correction I suggested, I think the rest is fine by me. I can't test it with Spyder because of the changes to |
|
Great, thanks @ccordoba12. We can check in at the meeting this morning, and merge today. |
The kernel 'channels' system had grown into a horribly tangled thicket of multiple inheritance code, using inheritance for three orthogonal differences: channel kind, blocking vs Qt, and ZMQ vs in-process. This is my attempt to trim it into some kind of clarity before we split the repos up (which will make doing this much harder).
execute()andinspect()) have all been moved from the channels to the KernelClient. They were already available on the kernel client by some proxying magic, but now they are actually define on the client class.message_receivedevent, and then looked at the message type again, so all the specific signals were unused. I have therefore removed them to make it more obvious what's going on.Doing this has allowed me to cut out lots of complex class inheritance and mixins. I briefly thought about trying to leave things in place for backwards compatibility, but I don't think there is any sane way to do that in this case. Hopefully, most consumers deal with the KernelClient class, which is largely unchanged.