[Tutor] How to run two os.system commands simultaneously

Kent Johnson kent37 at tds.net
Thu Dec 17 17:51:34 CET 2009


On Thu, Dec 17, 2009 at 10:14 AM, pedro <pedrooconnell at gmail.com> wrote:
> On 2009-12-17 09:52:34 -0500, Kent Johnson <kent37 at tds.net> said:
>
>> call os.system() in a thread
>
> Hi Kent, pardon my ignorance but what do you mean by call os.system() in a
> thread?

Your basic problem is that os.system() blocks - it waits until the new
process completes before continuing execution of your code. You don't
want to block - you want to be able to start the next process before
the first one completes.

One way to convert a blocking operation to a non-blocking one is to
start a new thread and run the blocking operation in the second
thread. Then the main program can continue, only the new thread is
blocked.

I think my first suggestion is simpler, though, especially if you
don't know what threads are.

Kent


More information about the Tutor mailing list