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


Groups > comp.lang.python > #8617

Re: Trying to chain processes together on a pipeline

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <bahamutzero8825@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'bug,': 0.09; 'encoder': 0.09; 'finally:': 0.09; 'omit': 0.09; "'-'": 0.16; "'-q',": 0.16; '1),': 0.16; 'close()': 0.16; 'error"': 0.16; 'okay,': 0.16; 'refactored': 0.16; 'subject:Trying': 0.16; 'windowserror': 0.16; 'working.': 0.19; 'header:In-Reply-To:1': 0.22; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'code': 0.24; 'says': 0.25; 'function': 0.26; '(the': 0.28; 'skip:p 30': 0.28; 'fixed': 0.29; 'blocks': 0.30; 'error': 0.31; "skip:' 10": 0.32; 'message-id:@gmail.com': 0.32; 'break': 0.33; "i've": 0.33; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; "can't": 0.34; 'try:': 0.35; "isn't": 0.35; 'but': 0.37; 'received:192': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'put': 0.38; 'received:192.168.1': 0.39; 'except': 0.39; 'skip:s 20': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'where': 0.40; 'chain': 0.66; 'exc:': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=TEP4rqvXh6TxDCurfOQZL1r06Db1hSAom+VgCfgkEoI=; b=Hqq0CsOpZtiOiF1FG7GB7ubbc1+Czz6ggSIg7C4dxj3IoGl3ned6jQQELM2pcadBCJ Sc/XN9aJE3KwbgtZs+Cw1Q8wAYcu5LoOhvEaG1W0cfmwijD75mXe0bcqH+U61anc0m6t brbeq/CRfqnTxSHdKgqF0ruaR7LEZ2/LPbU1M=
Date Thu, 30 Jun 2011 20:40:12 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 ThunderBrowse/3.3.5
MIME-Version 1.0
To "comp.lang.python" <python-list@python.org>
Subject Re: Trying to chain processes together on a pipeline
References <4E096D3B.3080300@gmail.com> <iubshf$dus$1@dough.gmane.org>
In-Reply-To <iubshf$dus$1@dough.gmane.org>
X-Enigmail-Version 1.1.1
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.532.1309484420.1164.python-list@python.org> (permalink)
Lines 70
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1309484420 news.xs4all.nl 21814 [2001:888:2000:d::a6]:48680
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8617

Show key headers only | View raw


Okay, so I've refactored those except WindowsError blocks into calls to
a function and fixed the os.devnull bug, but I still can't get the
triple chain working. I added calls to ffmpeg_proc.stdout.close() and
sox_proc.stdout.close(), but I really am not sure where to put them. The
following code works if SoX isn't part of the chain (that is, if vol ==
1), but not otherwise (the Nero encoder says "truncation error" after it
finishes; the same error I get if omit the close() calls):
> while True:
>     if queue[position].audio:
>         if queue[position].vol != 1:
>             queue[position].ffmpeg_cmd = [
>             queue[position].ffmpeg_exe,
>             '-i', queue[position].ifile,
>             '-f', 'sox', '-'
>             ]
>             queue[position].sox_cmd = [
>             queue[position].sox_exe,
>             '-t', 'sox', '-',
>             '-t', 'wav', '-',
>             'vol', str(queue[position].vol)
>             ]
>         else:
>             queue[position].ffmpeg_cmd = [
>             queue[position].ffmpeg_exe,
>             '-i', queue[position].ifile,
>             '-f', 'wav', '-'
>             ]
>         queue[position].nero_aac_cmd = [
>         queue[position].nero_aac_exe,
>         '-ignorelength',
>         '-q', str(queue[position].aac_quality),
>         '-if', '-',
>         '-of', queue[position].outdir + queue[position].prefix + '.m4a'
>         ]
>     print(queue[position].ffmpeg_cmd)
>     print(queue[position].sox_cmd)
>     print(queue[position].nero_aac_cmd)
>     try:
>         ffmpeg_proc = subprocess.Popen(queue[position].ffmpeg_cmd,
> stdout=subprocess.PIPE, stderr=open(os.devnull, 'w'))
>     except WindowsError as exc:
>         log_windows_error(exc, queue[position].ffmpeg_cmd, 'critical')
>         break
>     if queue[position].vol != 1:
>         try:
>             sox_proc = subprocess.Popen(queue[position].sox_cmd,
> stdin=ffmpeg_proc.stdout, stdout=subprocess.PIPE,
> stderr=open(os.devnull, 'w'))
>             wav_pipe = sox_proc.stdout
>         except WindowsError as exc:
>             log_windows_error(exc, queue[position].sox_cmd, 'critical')
>             break
>     else:
>         wav_pipe = ffmpeg_proc.stdout
>     try:
>         nero_aac_proc = subprocess.Popen(queue[position].nero_aac_cmd,
> stdin=wav_pipe)
>     except WindowsError as exc:
>         log_windows_error(exc, queue[position].nero_aac_cmd, 'critical')
>         break
>     finally:
>         ffmpeg_proc.stdout.close()
>         if queue[position].vol != 1:
>             sox_proc.stdout.close()
>     ffmpeg_proc.wait()
>     if queue[position].vol != 1:
>         sox_proc.wait()
>     nero_aac_proc.wait()
>     break

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


Thread

Re: Trying to chain processes together on a pipeline Andrew Berg <bahamutzero8825@gmail.com> - 2011-06-30 20:40 -0500
  Re: Trying to chain processes together on a pipeline Peter Otten <__peter__@web.de> - 2011-07-01 09:26 +0200
    Re: Trying to chain processes together on a pipeline Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-01 03:02 -0500
    Re: Trying to chain processes together on a pipeline Chris Rebert <clp2@rebertia.com> - 2011-07-01 01:24 -0700

csiph-web