Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Watching output and put back in background (http://www.velocityreviews.com/forums/t953609-re-watching-output-and-put-back-in-background.html)

Nobody 10-19-2012 02:22 PM

Re: Watching output and put back in background
 
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).



All times are GMT. The time now is 10:22 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57