Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7251
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'newbie': 0.03; 'wed,': 0.03; 'python.': 0.04; 'python?': 0.05; 'suppose': 0.05; 'subprocess': 0.09; 'pm,': 0.10; 'c++': 0.12; 'binary': 0.14; 'wrote:': 0.14; 'subject:python': 0.14; '"test"': 0.16; 'binaries': 0.16; 'proc': 0.16; 'cc:addr:python-list': 0.17; 'cheers,': 0.19; 'this?': 0.19; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; "what's": 0.23; 'code': 0.24; 'example': 0.27; "i'm": 0.27; 'message-id:@mail.gmail.com': 0.28; 'subject:?': 0.29; 'import': 0.29; 'all,': 0.30; 'subject:How': 0.30; 'cc:addr:python.org': 0.30; 'cmd': 0.30; 'anyone': 0.32; 'named': 0.32; 'question': 0.34; 'chris': 0.34; 'module.': 0.35; 'test': 0.35; 'running': 0.37; 'takes': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.37; 'parallel': 0.37; 'received:209.85.213': 0.37; 'two': 0.37; 'run': 0.38; 'subject:: ': 0.38; 'doing': 0.39; 'received:209': 0.39; 'subject:with': 0.39; 'best': 0.60; 'below': 0.61; '12:06': 0.84; 'bash:': 0.84; 'pony': 0.84; 'sender:addr:chris': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=xBN/GBpZRsP1wZBtUV89vX6JOggdMYBRU7HZ2Vm3SaU=; b=IE4njITKkLHIUeIvKul/z6VZ2NL1L4M9wnAtNn1QwX95AsrNfuNfIzYoDN1xR+mZgT PnZMcITwJ5zgz+Cw10Ut15u2VvgiFD98MhRN1GTYfzHPkCJXypTn3a/EvFO7LL/WgiGc /haNKhsx1/IyrzKzQ1QLxCyoe5UwUSvGOzoXw= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=Q3OqXc5ZWufCw0qoZhntswEe3ZosXfKJSOu3gdYWYV0+1sFfqC/lFahU+wtt0dTVpC yA16B4KD3mPNktgyYgICRjqCjb6ulQR4X3jolP3gro8sFgtEuyMwNRNW8PF1qrBnrYEh amxFJXVPcwQ9qRts8gdThxPvRtIWE5fvrTV+I= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <f2a96414-09b0-407f-aaf7-ff62b276734d@d1g2000yqe.googlegroups.com> |
| References | <f2a96414-09b0-407f-aaf7-ff62b276734d@d1g2000yqe.googlegroups.com> |
| Date | Wed, 8 Jun 2011 12:15:23 -0700 |
| X-Google-Sender-Auth | 3ebmTN6q6iX1fh_VsYX7hsEYjW4 |
| Subject | Re: How to run C++ binaries with python in parallel? |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Pony <lingyu.ma.fu@googlemail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| 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.29.1307560532.11593.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1307560532 news.xs4all.nl 49038 [::ffff:82.94.164.166]:59643 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7251 |
Show key headers only | View raw
On Wed, Jun 8, 2011 at 12:06 PM, Pony <lingyu.ma.fu@googlemail.com> wrote:
> Hi all,
>
> I'm a newbie with python, and I have a question about running parallel
> C++ binaries with python.
>
> Suppose I have a C++ binary named "test" and it takes two inputs, if I
> want to run below three commands in bash:
> test a b
> test c d
> test e f
>
> What's the best way to run it parallel with python?
Use the `subprocess` module.
> Can anyone give an example code for doing this?
from subprocess import Popen
cmds = [['test', 'a', 'b'], ['test', 'c', 'd'], ['test', 'e', 'f']]
processes = [Popen(cmd) for cmd in cmds]
for proc in processes:
proc.wait()
Cheers,
Chris
--
http://rebertia.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to run C++ binaries with python in parallel? Pony <lingyu.ma.fu@googlemail.com> - 2011-06-08 12:06 -0700 Re: How to run C++ binaries with python in parallel? Chris Rebert <clp2@rebertia.com> - 2011-06-08 12:15 -0700
csiph-web