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
Finish up embed_kernel #1640
Finish up embed_kernel #1640
Conversation
This patch adds IPython.embed_kernel() as a public API. Embedding an IPython kernel in an application is useful when you want to use IPython.embed() but don't have a terminal attached on stdin and stdout. My use case is a modern gdb with Python API support #!/usr/bin/gdb --python import IPython; IPython.embed_kernel() this way I get to use ipython to explore the GDB API without the readline librarry in gdb and ipython fighting over the terminal settings. A Google search revealed that other people were interetsted in this use case as well: http://mail.scipy.org/pipermail/ipython-dev/2011-July/007928.html
https://github.com/ipython/ipython/pull/1357/files#r400153 Stop embed_kernel() from parsing sys.argv since to support being called from a environments with their own command line args.
* `**kwargs` are passed to KernelApp for config * add docstring * IPython.zmq.ipapp.embed_kernel is now fully functional * allow re-entry to kernel
This looks great, @minrk, thanks! Your new commits pretty much finish up the job. The only thing I can think of is that I remembered we have these two examples (both of which depend on this file of kernel embedding. It would be great to update those examples to these cleaner APIs. But if you're swamped, I can do that in a separate PR, just let me know. In that case we'll merge this one and I'll do that later. |
Sure, I'll do that tomorrow. -MinRK On Apr 22, 2012, at 20:15, Fernando Perezreply@reply.github.com wrote:
|
On Sun, Apr 22, 2012 at 11:04 PM, Min RK
Awesome, thanks! |
Hm, those examples integrate a kernel, but don't seem to actually embed one (they aren't invoked into a specific namespace). I'm not sure how they would benefit from using embed_kernel. |
Right, but that's b/c when I first wrote them I had trouble making them a regular embedded example... Actually never mind: it's easier for me to clean these guys up once we merge this PR rather than asking you to read my mind :) Ignore those guys, and I'll clean them up as soon as I have a minute. With that aside, this looks good to go! Anything in your mind that we should hold for? |
Okay, I'll let you look into those, then. This seems good to me, then. |
Add IPython.embed_kernel() as a public API. Embedding an IPython kernel in an application is useful when you want to use IPython.embed() but don't have a terminal attached on stdin and stdout.
thanks everyone, this is great work! @scottt: we really appreciate your patience pushing this through multiple PRs. This particular feature is very important, so I'm thrilled to see it in. |
Add IPython.embed_kernel() as a public API. Embedding an IPython kernel in an application is useful when you want to use IPython.embed() but don't have a terminal attached on stdin and stdout.
This is just a few more commits on top of PR #1357, addressing the pending review on that one.
Changes, per review in #1357:
extract_module_locals_above
Extra edit, to better match
IPython.embed()
:**kwargs
to allow configuration of the kernel