Restart bash if we get an EOF error.

Restart bash if there are any errors

Limit catches to pexpect.EOF, print previous output

Catch keyboard interrupts while waiting for bash prompt

Revert try/catch around expect_prompt
main
Steven Silvester 11 years ago
parent f718dea58b
commit 8da70a352a

@ -1,6 +1,5 @@
from IPython.kernel.zmq.kernelbase import Kernel
from pexpect import replwrap
import pexpect
from pexpect import replwrap, EOF
import signal
from subprocess import check_output
@ -28,6 +27,9 @@ class BashKernel(Kernel):
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self._start_bash()
def _start_bash(self):
# Signal handlers are inherited by forked processes, and we can't easily
# reset it from the subprocess. Since kernelapp ignores SIGINT except in
# message handlers, we need to temporarily reset the SIGINT handler here
@ -52,9 +54,9 @@ class BashKernel(Kernel):
interrupted = True
self.bashwrapper._expect_prompt()
output = self.bashwrapper.child.before
except pexpect.EOF:
# TODO: how do we shut down gracefully here?
output = ''
except EOF:
output = self.bashwrapper.child.before + 'Restarting Bash'
self._start_bash()
if not silent:
stream_content = {'name': 'stdout', 'data': output}

Loading…
Cancel
Save