Re: [Tutor] Start multiple threads from Python

2013-08-07 Thread Chris Down
On 2013-08-05 12:17, Ryan Waples wrote:
> Currently I am calling each analysis program one at a time with
> subprocess.call(). This is working without a hitch, but as each analysis
> can take a while to run, I want to try to speed things up.  I realize I can
> start three different python sessions to do this, but that just begs the
> question how to do that from python?

subprocess.Popen does not block unless you explicitly tell it to (by using
communicate()). Perhaps that's what you want.

>>> import subprocess
>>> x = subprocess.Popen([ "sleep", "60" ])
>>> y = subprocess.Popen([ "sleep", "60" ])
>>> x.pid
3035
>>> y.pid
3036


pgp7_7NXZ0dcW.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Start multiple threads from Python

2013-08-05 Thread Ryan Waples
Thanks, that may be just what I'm looking for.

-ryan


On Mon, Aug 5, 2013 at 12:26 PM, Chris Down  wrote:

> On 2013-08-05 12:17, Ryan Waples wrote:
> > Currently I am calling each analysis program one at a time with
> > subprocess.call(). This is working without a hitch, but as each analysis
> > can take a while to run, I want to try to speed things up.  I realize I
> can
> > start three different python sessions to do this, but that just begs the
> > question how to do that from python?
>
> subprocess.Popen does not block unless you explicitly tell it to (by using
> communicate()). Perhaps that's what you want.
>
> >>> import subprocess
> >>> x = subprocess.Popen([ "sleep", "60" ])
> >>> y = subprocess.Popen([ "sleep", "60" ])
> >>> x.pid
> 3035
> >>> y.pid
> 3036
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Start multiple threads from Python

2013-08-05 Thread Ryan Waples
Python 2.7.x on Windows 7.

I'm looking for a bit of advice, not sure how to proceed.

With Python I am generating a file with a bunch of data in it.  I want to
analyse the data in this file with three separate programs.  Each of these
programs is single threaded needs only read access to the data, and they do
not depend on each other.

Currently I am calling each analysis program one at a time with
subprocess.call(). This is working without a hitch, but as each analysis
can take a while to run, I want to try to speed things up.  I realize I can
start three different python sessions to do this, but that just begs the
question how to do that from python?

How can I start multiple independent programs (as in subprocess.call())
without waiting for them to finish?

-Thanks
Ryan
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor