Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83312
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jeanpierreda@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.023 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'string': 0.09; 'exit': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'finish.': 0.16; 'grep': 0.16; 'mean,': 0.16; 'stderr': 0.16; 'stdout': 0.16; 'subject:threads': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'work,': 0.20; 'command': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'questions:': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'friends,': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'url:python': 0.33; 'running': 0.33; 'subject:with': 0.35; "can't": 0.35; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'step': 0.37; 'process,': 0.38; 'url:library': 0.38; 'pm,': 0.38; 'flow': 0.39; 'skip:. 10': 0.39; 'url:mail': 0.40; 'most': 0.60; 'tell': 0.60; 'success': 0.61; 'simple': 0.61; 'become': 0.64; 'to:addr:gmail.com': 0.65; '2015': 0.84; 'ing': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=DRICLSpOGgvk9wN26xXOT6TuWW/Gh8bNOO/L+dJgvc8=; b=YixeTbI2uyfhOBD/Ypd9fpGyn0wJEocDbJHMTKcD4CrHBLCa8BtyFdD1OuSBB1v3dP kGKRAJ80on2pyu+k3MYuTQac0QcQiMiyQrd0q+iXhQQglT/usGtQOjV5aVPCrZB+pbyI E+Cuafm+M/e63jt/OFGmbqkVWmP7O3ZJgPACMjUPWD8CpT+GJQ1UveACiDAMoSWkLP1N OFM4nx6+0Kamrxjc4QqXr7rZuo1E6D2ZQK/t71WqJbsiKeVNZbtTathbMtcImOs50ppy bmEFFibv+29bNbhmhBJj+hHKfDxcwmRtkWJciVUhx1UGbelum/dza3BlQ7WGNpibw4QZ ck6A== |
| X-Received | by 10.140.21.229 with SMTP id 92mr10052226qgl.33.1420683004450; Wed, 07 Jan 2015 18:10:04 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <CACT3xuWmGF7OpoTKmEHEwzzsZNPXECn-rDKVnDtUo8-p1B1fww@mail.gmail.com> |
| References | <CACT3xuUzuMH1CF3AsakdGMwa3U3BX3N+nA1ZVy4NhVmnA9-6gw@mail.gmail.com> <CACT3xuWmGF7OpoTKmEHEwzzsZNPXECn-rDKVnDtUo8-p1B1fww@mail.gmail.com> |
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | Wed, 7 Jan 2015 20:09:24 -0600 |
| Subject | Re: Playing with threads |
| To | Ganesh Pal <ganesh1pal@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | "comp.lang.python" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17459.1420683012.18130.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1420683012 news.xs4all.nl 2963 [2001:888:2000:d::a6]:53554 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83312 |
Show key headers only | View raw
I can't tell what you mean, but you can start a process via subprocess.Popen, do some work, and wait for it to finish. https://docs.python.org/2/library/subprocess.html Note that you don't need the stdout (or likely the stdin) of the process, you just need the return code -- whether or not grep succeeded -- so you can redirect stdout and stderr to os.devnull and avoid using .communicate(). Also, if you can't use .communicate(), but need to access stdout, this is the most common reason to need threads with subprocess. -- Devin On Wed, Jan 7, 2015 at 8:00 PM, Ganesh Pal <ganesh1pal@gmail.com> wrote: > Hi friends, > > I'm trying to use threads to achieve the below work flow > > 1. Start a process , while its running grep for a string 1 > 2. Apply the string 1 to the command in step 1 and exit step 2 > 3. Monitor the stdout of step1 and print success if the is pattern found > > Questions: > > 1. Can the above be achieved without threads ? I prefer keep ing code simple > .threads can become confusion when this workflow grows larger > > Regards, > Ganesh > > > -- > https://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Playing with threads Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-07 20:09 -0600
csiph-web