Threading question

Steve Holden sholden at holdenweb.com
Thu Apr 12 14:24:12 EDT 2001


"Jared Lee Peterson" <jared at tgflinux.com> wrote in message
news:mailman.987097937.1958.python-list at python.org...
> I have a question regarding threading in python.  Let me start by saying
> I am on a RedHat Linux 6.2 box with the standard python 1.5.2 that ships
> with it.  I am writing a test script that I need to spawn various
> threads.  I could probably do this without threads but I was curious to
> see how they work in python so I am trying to get them working.
> Basically I need to spawn a thread that is just making a system call
> (os.system()) to another script.  However when I create the thread with
> the target set it seems to call the other script just fine but the
> thread blocks execution and does it does not resume in the first script
> while that the other thread does it thing.  This is how I am spawning
> the thread ...
>
> tmp = Thread(target=os.system(other_script.py))
>
> Ideally I want to be able to loop over a list of scripts and spawn
> threads for each one and monitor their exectuion.  I have tried to look
> online for docs on python threading and there are none so if someone
> could help me out here that would be great.  It is probably obvious just
> by my email that I am not the threading master for sure.  Thanks a lot
>
I don't use threads much myself, but the docs suggest the statement you
quote only *creates* a thread, and that you will have to call its run()
method to start it executing. This would, I presume, require

tmp.run()

"""
run ()
Method representing the thread's activity.
You may override this method in a subclass. The standard run() method
invokes the callable object passed to the object's constructor as the target
argument, if any, with sequential and keyword arguments taken from the args
and kwargs arguments, respectively.
"""
(Library Manual, 7.5.6)

regards
 Steve






More information about the Python-list mailing list