Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:209.85.223': 0.03; 'output': 0.04; 'that?': 0.05; 'stderr': 0.09; 'thread': 0.11; 'to:name:python-list': 0.15; 'weird': 0.15; 'command,': 0.16; 'err': 0.16; 'shell': 0.18; 'second': 0.24; 'command': 0.24; 'possibly': 0.27; 'message-id:@mail.gmail.com': 0.27; 'initial': 0.28; 'run': 0.28; 'end,': 0.29; 'maybe': 0.29; 'error': 0.30; 'file': 0.32; 'could': 0.32; 'right?': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'possible': 0.37; 'one,': 0.37; 'quite': 0.37; 'received:209': 0.37; 'things': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'time,': 0.62; 'more': 0.63; 'hang': 0.65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=GJWd3vHC3tW6s7VpfxrJI/Bbvgz2HVt13nxsF3NqsOk=; b=TMuYJhkck94FGQ8vHH2mgB32BREGP1YcwfA7qumRjdpWTpMb8b77qyUj7UuFh8mkJb VETRI/sM99uWGN9yNX5u3Aop5tQCpVtpTubKVS3N/ZsnAswnegm2rw/d18vxSA4WANAt 6+qkP0QYxb21xoPLiU1cDyhGXxYShJsRj8tuNGGoBQxU24sJhDd9Uzbzw+DIH5AKPpC4 a/fBwpWF1exW0zDfXypAEEqKmmJeRdttE+ITgAcdOT2VuxcOzRrTgzbtusDadEHcIDzk F+OeSIRCogl35YvGKJeVeAeezZBCXuGoB6faSoNVtm4JxVE9HP/3Zj5LXfJHV2FjnLOt LWlg== MIME-Version: 1.0 Date: Thu, 18 Oct 2012 14:05:58 +0100 Subject: Watching output and put back in background From: andrea crotti To: python-list Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350565561 news.xs4all.nl 6902 [2001:888:2000:d::a6]:44928 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31632 In one process I need to run many quite weird shell commands that take a long time, possibly in parallel. Now the problem is that I need to catpure the initial standard error of the command and then I can go on with the second one, but how can I do that? It should be something like Popen(long_command..) - first line output - second line - interesting line .. more things .. But if I just do out, err = proc.communicate() it will hang there until the end, right? 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.. Ideas?