Re: Watching output and put back in background

Discussion in 'Python' started by Nobody, Oct 19, 2012.

  1. Nobody

    Nobody Guest

    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).
     
    Nobody, Oct 19, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Richards
    Replies:
    0
    Views:
    352
    Paul Richards
    Dec 11, 2003
  2. Luis Esteban Valencia Muñoz
    Replies:
    3
    Views:
    1,421
    Scott Allen
    Jun 4, 2005
  3. Dusan Micuch

    Watching my Packet TCP and UDP

    Dusan Micuch, Jun 12, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    443
    bruce barker \(sqlwork.com\)
    Jun 12, 2006
  4. Yoav
    Replies:
    1
    Views:
    274
    Diez B. Roggisch
    Aug 22, 2005
  5. Zed A. Shaw
    Replies:
    28
    Views:
    602
    Paul Boddie
    May 8, 2008
Loading...

Share This Page