##// END OF EJS Templates
Merge pull request #4305 from minrk/even-more-ways-to-get-ifaces...
Merge pull request #4305 from minrk/even-more-ways-to-get-ifaces Add even more ways to populate localinterfaces use netifaces for faster IPython.utils.localinterfaces when availlable, Parse subprocess output from ifconfig / ip addr / ipconfig. Lower priority than netifaces, but still higher priority than socket.gethostbyname. Fallback to gethostname otherwise. Should be much faster in worst case scenario where machine are badly configurred and can wait up to ~30s to start ipython. Slighly slower in other cases.

File last commit:

r11360:f3aabe2e
r12911:aeeb7f5a merge
Show More
embedded_terminal.py
30 lines | 794 B | text/x-python | PythonLexer
import os
from IPython.kernel.inprocess import InProcessKernelManager
from IPython.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(manager=kernel_manager, client=client)
shell.mainloop()
if __name__ == '__main__':
main()