##// END OF EJS Templates
add in-process kernel examples
add in-process kernel examples

File last commit:

r10305:4a8ebe8e
r10305:4a8ebe8e
Show More
embedded_terminal.py
30 lines | 817 B | text/x-python | PythonLexer
MinRK
add in-process kernel examples
r10305 import os
from IPython.kernel.inprocess import InProcessKernelManager
from IPython.frontend.terminal.console.interactiveshell import ZMQTerminalInteractiveShell
def print_process_id():
print 'Process ID is:', os.getpid()
def main():
print_process_id()
# Create an in-process kernel
# >>> print_process_id()
# will print the same process ID as the main process
kernel_manager = InProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
kernel.gui = 'qt4'
kernel.shell.push({'foo': 43, 'print_process_id': print_process_id})
client = kernel_manager.client()
client.start_channels()
shell = ZMQTerminalInteractiveShell(kernel_manager=kernel_manager, kernel_client=client)
shell.mainloop()
if __name__ == '__main__':
main()