Threading question
Steve Holden
sholden at holdenweb.com
Thu Apr 12 14:43:40 EDT 2001
"Jared Lee Peterson" <jared at tgflinux.com> wrote in message
news:mailman.987097937.1958.python-list at python.org...
[ ... ]
This is how I am spawning
> the thread ...
>
> tmp = Thread(target=os.system(other_script.py))
>
Note, also, that this statement requires the os.system() command to complete
before the Thread creation completes. The target should be a function
which, *when executed*, invokes os.system() on your script (whose name, I
assume, should have been a string constant).
> 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
>
For a single script, you appear to need something like
def do_my_script():
return os.system("other_script.py")
tmp = Thread(target=do_my_script)
tmp.start()
For multiple scripts, read the documentation about the Thread object and
argument passing.
The threading module is documented at
http://www.python.org/doc/1.5.2/lib/module-threading.html
but you should have local copies as a part of your installation. Look in
/usr/doc/python-docs-1.5.2/
You will probably also appreciate Aahz' work at
http://starship.python.net/crew/aahz/IPC9/index.html
regards
Steve
More information about the Python-list
mailing list