[IPython-dev] Issues with shell commands in IPython Notebook (Windows version)

Thomas Kluyver takowl at gmail.com
Wed Sep 24 13:57:48 EDT 2014


I think I see it. See IPython.utils._process_win32._system_body(). It will
read all of stdout, and then all of stderr. If a process is writing a lot
to stderr (as it looks like wget is), it will fill up a buffer, then hang,
because we're still trying to read stdout.

We could use Popen.communicate() for this, though that's still not going to
get you output updating in real time. Trying to do real time output
properly might be more tricky.

Thomas

On 24 September 2014 02:47, Matthias Bussonnier <
bussonniermatthias at gmail.com> wrote:

> Hi,
>
> !, is a shortcut for the magic %sx that in the end wrap subprocess, if you
> want to track down :
>
> IPython.core.interactiveshell:system
> IPython.utils.process:getoutput
> IPython.utils._process_common:process_handle
>
> p = subprocess.Popen(cmd, shell=isinstance(cmd, py3compat.string_types),
>                          stdin=subprocess.PIPE,
>                          stdout=subprocess.PIPE,
>                          stderr=stderr,
>                          close_fds=close_fds)
>
> The limitation are the limitation of subprocess, and the limitation of
> user testing and developing on windows.
> History can show you that not many windows de/user did care about this,
> and with no windows machine its hard to help.
>
>
> https://github.com/ipython/ipython/commits/master/IPython/utils/_process_common.py
>
> If you can try with Popen directly, and make it to work we can probably
> adapt the logic.
> --
> M
>
>
>
> Le 24 sept. 2014 à 10:48, Kenneth Tran a écrit :
>
> I have 2 instances of IPython NBServer running, one runs on Linux and the
> other runs on Windows. Let's call them NB-Win and NB-Linux. On both
> machines, IPython was installed using Anaconda.
>
> The experience of calling shell commands on NB-Win has been terrible. Many
> commands hang for no reason.
>
> I've tried
>
> *!wget
> http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/kddb.t.bz2
> <http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/kddb.t.bz2>*
>
> (which is just 25MB) in a notebook on both servers.
>
> *On NB-Win*
> The command always failed to terminate. It hangs like this forever
>
> <image.png>
>
> When I looked at the *wget* process in Process Explorer, none of the
> numbers (CPU, memory, IO, network, etc.) moved. If I killed the process,
> then now the cell returned something, like this
>
> <image.png>
>
> The experience is the same with other commands. For example, I tried going
> to a directory and calling *!make*, and that one also didn't terminate.
>
> For comparison, this is what looks like when I run the same command
> using NB-Linux. The output is displayed as the program is running and the
> program exits in a few seconds.
> <image.png>
>
> *So my questions are*
>
>    1. Why does the above command above (as well as many others) hang in
>    NB-Win? (I could replicate this issue easily on my other Windows machines.)
>    2. Why can't NB-Win display console output in real-time as the program
>    is running? While both NB-Linux and IPython shell on Windows/Linux can.
>    3. Why does NB-Win display a different output (or error?) string than
>    what IPython-Win shell (on the same machine) produces? Both invoke the same
>    *C:\Cygwin\bin\wget.exe* command line.
>
> <image.png>
>
>
> Those issues have driven me crazy. I would appreciate any help.
>
> -Ken
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140924/5e798fee/attachment.html>


More information about the IPython-dev mailing list