Skip to content
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

Support control<>iopub messages to e.g. unblock comm_msg from command execution #1114

Merged
merged 2 commits into from
May 5, 2023

Conversation

tkrabel-db
Copy link
Contributor

Disclaimer: I work for Databricks, where we patched the control channel to handle jupyter messages like comm_open and comm_msg.

What changes with this PR?

At Databricks (which uses ipykernel), we often face the situation that customers execute long running pyspark jobs which block the shell channel for minutes or even an hour. In order to provide a better user experience, we unblock some original shell messages by moving them over to the control channel. We successfully did that with complete_request, comm_open and comm_msg.

Part of our fix was changing the comm object so that it gets the parent header from the correct thread. My PR is about that change.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@blink1073 blink1073 merged commit c698d27 into ipython:main May 5, 2023
28 of 32 checks passed
@tkrabel-db
Copy link
Contributor Author

@jasongrout FYI. This went faster than expected :)

@maartenbreddels
Copy link
Contributor

Just for the record: this does not change existing behavior? This only supports your use case of sending back to the right channel if that happens. So this is totally backward compatible, right?

@tkrabel-db
Copy link
Contributor Author

tkrabel-db commented May 8, 2023

Yes. The existing behaviour is shell<>iopub channel communication, which still works as expected. This change supports adding control<>iopub channel communication without the necessity of patching internal ipykernel functions, which is what we had to do at Databricks so far.

@jasongrout
Copy link
Member

Awesome, thanks for reviewing this, @blink1073.

I talked with @minrk about this yesterday night too, and he suggested that this if statement would be better positioned in the get_parent function, so that it could be used by not only comms, but by anyone getting the appropriate parent header in a thread. More concretely, he suggested the logic for picking the right parent header be implemented at

return self._parents.get(channel, {})
and we change the signature of get_parent to something like get_parent(self, channel=None) (where the default None value means to use this logic to determine the correct parent header).

@tkrabel-db - what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants