<div>Hi everyone.<br></div><div><br></div><div>I've been trying to implement from the examples in <a href="http://github.com/ellisonbg/pyzmq">pyzmq</a> the support for raw_input calls, to be used in IPthonZMQ and IPythonQt projects.</div>
<div>Nothing goo has come from this attempts but a better understanding of what I don't understand. Here's a guide through my last thoughts so you can help me:</div><div><br></div><div>firs I wanted to add to this line(154) in the kernel, a new type of request:</div>
<div><strong><br></strong></div><div><strong>for msg_type in ['execute_request', 'complete_request','</strong><font color="#ff0000"><strong>raw_input_request</strong></font><strong>']:</strong><strong><br>
</strong><strong>                self.handlers[msg_type] = getattr(self, msg_type)</strong><br></div><div><br></div><div>Also I need to add a function:</div><div><strong><br></strong></div><div><strong>def raw_input_request(self,ident,parent):</strong></div>
<div><strong>   print>>sys.__stdout__,"entered"</strong></div><div><strong><br></strong></div><div>Just to check if the messages thread gets there (Which it doesn't).<strong><br></strong></div><div>The class RawInput is as it was always.</div>
<div>And obviously the overwriting of the raw_input function in main():</div><div><br></div><div><strong>rawinput=RawInput(session,pub_socket)<br>    __builtin__.raw_input=rawinput</strong><br></div><div><strong><br></strong></div>
<div>Now for the frontend part, I need also a msg_type:<strong><br></strong></div><div><br></div><div><strong>for msg_type in ['pyin', 'pyout', 'pyerr', 'stream','<font color="#ff0000">raw_input</font>']:<br>
                self.handlers[msg_type] = getattr(self, 'handle_%s' % msg_type)</strong><br></div><div><br></div><div>And a handler for raw_input type of messages:</div><div><br></div><div><strong>def handle_raw_input(self,omsg):<br>
            stdin_msg=sys.stdin.readline()<br>            src=stdin_msg<br>            self.session.send(self.request_socket,'raw_input_request',dict(code=src))</strong><br></div><div><br></div><div>As you can see this is just to send the raw_input request with the line written by the user.</div>
<div>The error is this:</div><div><br></div><div><strong><class 'zmq._zmq.ZMQError'> : Operation not supported<br>Traceback (most recent call last):<br>  File "./kernel.py", line 194, in execute_request<br>
    exec comp_code in self.user_ns, self.user_ns<br>  File "<zmq-kernel>", line 1, in <module><br>  File "./kernel.py", line 126, in __call__<br>    reply=self.socket.recv_json()<br>  File "_zmq.pyx", line 906, in zmq._zmq.Socket.recv_json (zmq/_zmq.c:6862)<br>
  File "_zmq.pyx", line 751, in zmq._zmq.Socket.recv (zmq/_zmq.c:5316)<br>  File "_zmq.pyx", line 781, in zmq._zmq.Socket._recv_copy (zmq/_zmq.c:5690)<br>ZMQError: Operation not supported</strong><br></div>
<div><strong><br></strong></div><div>It says that the error is in <em><strong>exec</strong> comp_code <strong>in</strong> self.user_ns, self.user_ns</em>, which is in the execute_request function</div><div><br></div><div>
{u'content': {u'code': u'raw_input()'},                                                                                                                <br> u'header': {u'username': u'muzgash', u'msg_id': 0, u'session': u'264d21d4-7e00-4b7e-b051-3c0ba7b221f6'},<br>
 u'msg_type': u'<font color="#ff0000">execute_request</font>',<br> u'parent_header': {}}<br></div><div><br></div><div>{'content': {u'status': u'<font color="#ff0000">error</font>', u'etype': u"<class 'zmq._zmq.ZMQError'>", u'evalue': u'Operation n..........</div>
<div><br></div><div>so I can say that the error is in the first message sent by the frontend to the kernel, but the raw_input function is called ( RawInput.__call__() ) and also a message is sent to the frontend through:</div>
<div><br></div><div>msg = self.session.msg(u'raw_input')<br>        self.socket.send_json(msg)<br></div><div><br></div><div>and the function handle_raw_input is called, which sends a new message to the kernel</div>
<div><br></div><div>{u'content': {u'code': u'input-->\n'},<br> u'header': {u'username': u'muzgash', u'msg_id': 1, u'session': u'264d21d4-7e00-4b7e-b051-3c0ba7b221f6'},<br>
 u'msg_type': u'<font color="#ff0000">raw_input_request</font>',<br> u'parent_header': {}}<br></div><div><br></div><div>so this line in the class RawInput should recieve it:</div><div><br></div><div>
while True:<br>                try:<br>                        reply = self.socket.recv_json(zmq.NOBLOCK)<br></div><div><br></div><div>But it doesn't.</div><div><br></div><div>That's one thing.</div><div>Another one is that for this to work well in the Qt frontend I need to fix pyout (keeping off course multiline input) which I have no clue how to do it.</div>
<div>I could write a pretty crude fix with Qt and without requesting the kernel twice, but no _NN call will work and it will have to be rewritten when this problems are solved.</div><div>So I think for now I'll move on to the next point in the schedule 'till some ideas popup.</div>
<div><br></div><div><br></div><div>thanks in advance.</div><div><br></div><div><font color="#888888"><br><br>Best regards.<br>--<br><a href="http://he1.udea.edu.co/gweb" target="_blank">Gerardo Gutiérrez Gutiérrez</a><br>
Physics student<br>Universidad de Antioquia<br>Computational physics and astrophysics group (<a href="http://urania.udea.edu.co/sites/sites.php" target="_blank">FACom</a>)<br>


Computational science and development branch(<a href="http://urania.udea.edu.co/sites/facom-dev/" target="_blank">FACom-dev</a>)<br>Usuario Linux #492295</font><br><br>
<br>
<br></div><div><br></div>