[IPython-user] IPShellEmbed only stops once

Fernando Perez fperez.net@gmail....
Mon Nov 26 01:31:05 CST 2007


Hi Dave,

On Jun 8, 2007 11:47 AM, Dave Kuhlman <dkuhlman@rexx.com> wrote:
> I recently ran into the following problem -- If I run a program
> that creates several calls to an embedded shell, when I type
> Ctrl-D at the first break, it exits from the embedded shell, and
> also automatically exits from all subsequent shells without
> pausing.
>
> Has anyone else run into this?  I looked for a flag in my
> ipythonrc that might control this, but could not find anything.
>
> Must be something simple that I'm doing wrong.  But, I can't
> figure out what.
>
> I'm on Ubuntu GNU/Linux using Python 2.5.1 and IPython 0.8.1.
>
> Here are some things that I've done to try to fix this:
>
> - I've tried running under several shells, for example Konsole
>   (KDE), Eterm, and xterm, but get the same result.
>
> - I installed the latest IPython (0.8.1).  I cleared out my
>   ~/.ipython directory, to make sure that IPython installed the
>   latest .ipythonrc.  I get the same result.
>
> - I tried running my test (see below) with a different version of
>   Python.  I get the same result.
>
> - I checked the value returned by ipshell.get_dummy_mode().  It's
>   zero, which means that it should enter the shell at each call to
>   ipshell, right?
>
> If anyone has a suggestion, I'd like to hear it.  Thanks in advance.
>
> Here is a simple test:
>
> # ======================================
> from IPython.Shell import IPShellEmbed
> args = ['-pdb', '-pi1', 'In <\\#>: ', '-pi2', '   .\\D.: ',
>     '-po', 'Out<\\#>: ', '-nosep']
> ipshell = IPShellEmbed(args,
>     banner = 'Entering IPython.  Press Ctrl-D to exit.',
>     exit_msg = 'Leaving Interpreter, back to program.')
>
> def breaks():
>     ipshell('one')
>     ipshell('two')
>     ipshell('three')
>
> breaks()
> # ======================================
>
> And here is the output:
>
> # ======================================
> Entering IPython.  Press Ctrl-D to exit.
> one
> In <1>:
> Do you really want to exit ([y]/n)? y
> Leaving Interpreter, back to program.
> Leaving Interpreter, back to program.
> Leaving Interpreter, back to program.
> # ======================================
>
> Notice that IPShellEmbed does not print a prompt and stop after
> the first call to ipshell.

Sorry I never replied, but I know I fixed this a while back (it bit me
one day while working and I went ahead and fixed it, but as you can
probably tell from today's flood, I was badly behind on email
maintenance).

So if you grab SVN or the upcoming 0.8.2, this now works.  Using your example:

tlon[~/tmp]> python embtest.py
Entering IPython.  Press Ctrl-D to exit.
one
In <1>:
Leaving Interpreter, back to program.
Entering IPython.  Press Ctrl-D to exit.
two
In <2>:
Leaving Interpreter, back to program.
Entering IPython.  Press Ctrl-D to exit.
three
In <3>:
Leaving Interpreter, back to program.


Cheers,

f


More information about the IPython-user mailing list