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


Groups > comp.lang.python > #92099

Re: Multiple thread program problem

Date 2015-06-05 08:58 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: Multiple thread program problem
References <ff2d1eb5-95b7-4cfb-b259-c93ea244abc4@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.180.1433458695.13271.python-list@python.org> (permalink)

Show all headers | 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