Since the necessity of a user to keep his data safe, the design is based in a 2-process model that will be achieved with a simple client/server system with pyzmq, so the GUI session do not crash if the the kernel process does. This will be achieved using this test code and customizing it to the necessities of the GUI such as queue management with discrimination for different frontends connected to the same kernel and tab completion. A piece of drafted code for the kernel (server) should look like this:
c = zmq.Context(1, 1)
ip = '127.0.0.1'
port_base = 5555
connection = ('tcp://%s' % ip) + ':%i'
rep_conn = connection % port_base
pub_conn = connection % (port_base+1)
print >>sys.__stdout__, "Starting the kernel..."
print >>sys.__stdout__, "On:",rep_conn, pub_conn
session = Session(username=u'kernel')
reply_socket = c.socket(zmq.XREP)
pub_socket = c.socket(zmq.PUB)
stdout = OutStream(session, pub_socket, u'stdout')
stderr = OutStream(session, pub_socket, u'stderr')
sys.stdout = stdout
sys.stderr = stderr
display_hook = DisplayHook(session, pub_socket)
sys.displayhook = display_hook
kernel = Kernel(session, reply_socket, pub_socket)
This kernel will use two queues (output and input), the input queue will have id of the process(frontend) making the request, type(execute, complete, help, etc) and id of the request itself and the string of code to be executed, the output queue will have basically the same information just that the string is the to be displayed. This model is because the kernel needs to maintain control of timeouts when multiple requests are sent and keep them indexed.
QT BASED GUI
Design of the interface is going to be based in cells of code executed on the previous defined kernel. It will also have GUI facilities such toolboxes, tooltips to autocomplete code and function summary, highlighting and autoindentation. It will have the cell kind of multiline edition mode so each block of code can be edited and executed independently, this can be achieved queuing QTextEdit objects (the cell) giving them format so we can discriminate outputs from inputs. One of the main characteristics will be the debug support that will show the requested outputs as the debugger (that will be on a popup widget) "walks" through the code, this design is to be reviewed with the mentor.
The GUI will check continuously the output queue from the kernel for new information to handle. This information have to be handled with care since any output will come at anytime and possibly in a different order than requested or maybe not appear at all, this could be possible due to a variety of reasons(for example tab completion request while the kernel is busy processing another frontend's request). This is, if the kernel is busy it won't be possible to fulfill the request for a while so the GUI will be prepared to abandon waiting for the reply if the user moves on or a certain timeout expires.