Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31746

Re: Watching output and put back in background

From Nobody <nobody@nowhere.com>
Subject Re: Watching output and put back in background
Date 2012-10-19 15:22 +0100
Message-Id <pan.2012.10.19.14.22.39.494000@nowhere.com>
Newsgroups comp.lang.python
References <mailman.2428.1350565561.27098.python-list@python.org>
Organization Zen Internet

Show all headers | View raw


On Thu, 18 Oct 2012 14:05:58 +0100, andrea crotti wrote:

> Maybe a solution would be to redirect the stderr to file and watch that
> instead..
> 
> Or otherwise I could use a thread for each shell command, but I would like
> to avoid head-aches with possible race-conditions..

If you're running multiple concurrent commands, and you have redirected
their output streams to pipes, something needs to keep reading those pipes
if you don't want the commands to hang.

Rather than having a separate thread for each process, you could have a
single thread which manages all "background" processes using select(),
poll() or non-blocking I/O, but that's easier to do on Unix than on
Windows (Popen.communicate() uses a pair of threads on Windows).

Redirecting output to files then reading them upon completion is the
simplest solution, but you can't easily monitor progress that way (there's
no easy way to get notification when more output is written).

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Watching output and put back in background andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 14:05 +0100
  Re: Watching output and put back in background Nobody <nobody@nowhere.com> - 2012-10-19 15:22 +0100

csiph-web