Friday, 15 August 2014

python - Execute code on main IPython thread from within the running kernel -


I would like to queue some code from within the running kernel to execute on the main iphone thread. In other words, I want to do something like this (this is a pseudocode - I am not getting an API to do this).

  IPython.current_kernel.queue_execution ("print 'FOO'")  

I know that I IPython.kernel.connect.get_connection_file ( ) to get information about the current kernel connection. And then I can create a customer with that connection file. But I would ideally prefer a way to do this without connection. Is there any way to do this?

I am using IPhthan 2.4.

I have found a solution that works for my experiment case in case of my use , The kernel is used by IPython.kernel.multikernelmanager.MultiKernelManager (which runs the kernel out-of-pro). This is different from the kernel running process (such as when you run the iPython console by starting ipython.exe).

So for my out-of-pro kernel case, the following works:

  zmq.eventloop.ioloop.IOLoop.current (). Add_callback (my_callback)  

I do not know why it does not really work in-the-pre-kernel case Probably because when you are running the iPython console, the main thread is doing the whole time (estimate) console I / O.


No comments:

Post a Comment