-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
extract send_execute_reply method from Kernel.execute_request #7713
Conversation
@@ -699,3 +701,14 @@ def _at_shutdown(self): | |||
self.session.send(self.iopub_socket, self._shutdown_message, ident=self._topic('shutdown')) | |||
self.log.debug("%s", self._shutdown_message) | |||
[ s.flush(zmq.POLLOUT) for s in self.shell_streams ] | |||
|
|||
def _flush_execute_output(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.
Naming point: 'execute output' implies something a bit different. I would call this _flush_stdstreams
.
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.
It is specific to execute command because it sleeps for _execute_sleep
delay, that's why I added 'execute' to the name. But there are other places where this function can be useful - should they also sleep? If so, I think it could make sense to rename _execute_sleep
.
Does this logic suggest that all replies should be separated from their handler methods, rather than just execute replies? |
# Handle the reply message | ||
content = parent[u'content'] | ||
stop_on_error = content.get('stop_on_error', True) | ||
silent = content[u'silent'] |
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.
stop_on_error
and silent
are only used once below, it's probably not necessary to assign them to variables again.
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.
I'd even add another variable for reply_msg['content']['status'] == u'error'
to make the condition below nicer :) I'll remove it if you want.
In principle I think this is fine. |
@minrk a good point. Generally, yes; it is just that copy-paste savings are smaller for other methods. |
Do you plan on working on this soon? If not, do you mind if we close it until work restarts? We are doing major refactoring in the repo (our "Big Split") and existing PRs are going to bit-rot quickly (already). |
Hi @ellisonbg, No, I don't have plans to work on it soon. I'll open a new PR if I have time in future. For the record: the current hack-ish solution lives here; there is one more problem with async methods which is worked around there ("idle" event was published too early). |
This is related to #7614: I want
do_execute
method to be async. Currently the wholeexecute_request
should be copy-pasted to implement it; after this refactoring it is possible to return a deferred fromdo_execute
and add a callback to it in overriddensend_execute_reply
which calls parent'ssend_execute_reply
.Example: