[Tutor] Start multiple threads from Python

Chris Down chris at chrisdown.name
Mon Aug 5 21:26:30 CEST 2013


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20130805/08e055be/attachment.pgp>


More information about the Tutor mailing list