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


Groups > comp.lang.python > #92099

Re: Multiple thread program problem

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.045
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; 'tom': 0.07; 'guys.': 0.09; 'terminate.': 0.09; 'thread': 0.10; '"with"': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'function).': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'simpson': 0.16; 'subject:program': 0.16; 'wrote:': 0.16; 'later': 0.16; 'suggested': 0.20; 'subject:problem': 0.22; 'leave': 0.23; 'cheers,': 0.24; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'ride': 0.27; 'loop,': 0.29; 'usable': 0.29; 'code:': 0.29; 'read,': 0.29; 'values': 0.30; 'work.': 0.30; 'call.': 0.31; 'code': 0.31; 'up.': 0.32; 'point': 0.33; 'form.': 0.34; 'know.': 0.34; 'to:addr:python-list': 0.35; 'returning': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'skip:p 20': 0.38; 'to:addr:python.org': 0.39; 'some': 0.40; 'content- disposition:inline': 0.60; 'your': 0.60; 'hear': 0.62; 'more.': 0.62; 'more': 0.62; 'waiting': 0.63; 'here': 0.66; 'cameron': 0.66; 'saving': 0.70; 'received:61': 0.72; '>from': 0.76; '>def': 0.84; 'received:120': 0.84; 'suggestion,': 0.84; 'glad': 0.86
X-Authentication-Info Submitted using ID cskk@bigpond.com
X-Authority-Analysis v=2.0 cv=XNWyuHdE c=1 sm=1 a=oHOc5IGGHcvhHbJD6cfwrA==:17 a=yEdEr6MRgwAA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=XAFQembCKUMA:10 a=pGLkceISAAAA:8 a=U7UbAiMzAAAA:8 a=tfGn7W3XqXPbtyz83-YA:9 a=CjuIK1q_8ugA:10 a=oHOc5IGGHcvhHbJD6cfwrA==:117
Date Fri, 5 Jun 2015 08:58:00 +1000
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: Multiple thread program problem
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <ff2d1eb5-95b7-4cfb-b259-c93ea244abc4@googlegroups.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <ff2d1eb5-95b7-4cfb-b259-c93ea244abc4@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.180.1433458695.13271.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1433458695 news.xs4all.nl 2965 [2001:888:2000:d::a6]:56314
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:92099

Show key headers only | View raw


On 04Jun2015 10:20, M2 <mohan.mohta@gmail.com> wrote:
>Awesome Cameron.
>It works the way I want it to work.

Glad to hear it. A few small remarks:

>Thanks a lot guys.
>Here is the new code:
[...]
>from thread import start_new_thread

You're not using this any more. You may want to tidy this up.

>def proc(col) :
>        P=subprocess.Popen(col, shell=True)
>        return

You are not returning P. But ...

>        co=str("ssh -B ")+ str(com2) + str(com3)
>        P=proc(co)

Here you are saving the return value as P (local to this function). My 
suggestion, I know. The point here is that in later code you might save all the 
P values and call P.wait() for them at some point after the loop, waiting for 
them to terminate. Or you may not care. Your call.

>f.close()

Consider adding the suggested "with" form. Shorter, easier to read, more 
reliable.

Cheers,
Cameron Simpson <cs@zip.com.au>

Ride fast
Die fast
Leave no usable organs
        - Tom Warner <tom@dfind.demon.co.uk>

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


Thread

Multiple thread program problem Mohan Mohta <mohan.mohta@gmail.com> - 2015-06-03 13:41 -0700
  Multiple thread program problem Sam Raker <sam.raker@gmail.com> - 2015-06-03 14:01 -0700
    Re: Multiple thread program problem Mohan Mohta <mohan.mohta@gmail.com> - 2015-06-03 15:23 -0700
      Re: Multiple thread program problem Mohan Mohta <mohan.mohta@gmail.com> - 2015-06-03 16:45 -0700
        Re: Multiple thread program problem sohcahtoa82@gmail.com - 2015-06-03 16:56 -0700
          Re: Multiple thread program problem M2 <mohan.mohta@gmail.com> - 2015-06-03 17:04 -0700
            Re: Multiple thread program problem Cameron Simpson <cs@zip.com.au> - 2015-06-04 10:37 +1000
              Re: Multiple thread program problem M2 <mohan.mohta@gmail.com> - 2015-06-03 19:59 -0700
                Re: Multiple thread program problem Cameron Simpson <cs@zip.com.au> - 2015-06-04 14:42 +1000
  Re: Multiple thread program problem MRAB <python@mrabarnett.plus.com> - 2015-06-03 21:59 +0100
  Re: Multiple thread program problem Gary Herron <gherron@digipen.edu> - 2015-06-03 15:02 -0700
  Re: Multiple thread program problem M2 <mohan.mohta@gmail.com> - 2015-06-04 10:20 -0700
    Re: Multiple thread program problem Cameron Simpson <cs@zip.com.au> - 2015-06-05 08:58 +1000

csiph-web