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: 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 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: User-Agent: Mutt/1.5.23 (2014-03-12) References: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 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 On 04Jun2015 10:20, M2 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 Ride fast Die fast Leave no usable organs - Tom Warner