[IPython-dev] about ipython-zmq
Omar Andrés Zapata Mesa
andresete.chaos at gmail.com
Sun Jul 25 19:21:54 EDT 2010
Hi all.
crtl+c is done! you can see de code in
http://github.com/omazapa/ipython/tree/master/IPython/zmq/
I wrote a new message type in this frontend`s method
def get_kernel_pid(self):
omsg = self.session.send(self.request_socket,'pid_request')
while True:
#print "waiting recieve"
rep = self.session.recv(self.request_socket)
if rep is not None:
self.kernel_pid=rep['content']['pid']
break
time.sleep(0.05)
return self.kernel_pid
and y this one in kernel's class
def pid_request(self,ident,parent):
pid_msg = {u'pid':self.kernel_pid,
'status':'ok'}
self.session.send(self.reply_socket, 'pid_reply',pid_msg,
parent, ident)
then we have a new reuqest's type ''execute_request', 'complete_request',
'pid_request'
frontend's class have the attribute kernel_pid and I call get_kernel_pig()
in the constructor.
then when I have captured KeyboardInterrupt send signal SIGINT with kill
it is working.
O
2010/7/25 Fernando Perez <fperez.net at gmail.com>
> On Sun, Jul 25, 2010 at 2:38 PM, Brian Granger <ellisonbg at gmail.com>
> wrote:
> >
> > I think it is a little dangerous to forward Ctrl-C. When there are two
> > processes like this I think it is very ambiguous as to what it means. I
> > would rather go with a frontend magic:
> > :kernel 0 kill
>
> I really think we do need Ctrl-C. It would be pretty awful to have an
> interactive environment (especially for the line-based, blocking ones
> like the plain terminal Omar is working on and Evan's) where Ctrl-C
> doesn't just stop the kernel, at least on platforms where we can send
> processes signals. Given that the frontend does no real computation,
> what other semantics should Ctrl-C have?
>
> >> In order to do this, you'll need to know the PID of the kernel
> >> process, but Evan has already been making progress in this direction
> >> so you can benefit from his work. This code:
> >>
> >>
> >>
> http://github.com/epatters/ipython/blob/qtfrontend/IPython/zmq/kernel.py#L316
> >>
> >> already has a kernel launcher prototype with the necessary PID
> >> information.
> >>
> >
> > Let's start to use the Popen interface of Python 2.6. It has a terminate
> > and kill method that gets around the PID stuf in a cross platform manner.
>
> subprocess kill only sends SIGKILL, while os.kill allows the sending
> of any signal, so I'm not sure it completely replaces os.kill for us.
> But for subprocess cleanup then yes, I'm all for using it (especially
> if it works reliably in Windows).
>
> Cheers,
>
> f
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20100725/f05d25b2/attachment.html>
More information about the IPython-dev
mailing list