Multiple Processes on Unix with Python
Nickson Fong
nickson at centropolisfx.com
Fri Mar 23 00:28:46 EST 2001
this is helpful - what i really want to do is>
for example: i have a 2 processor irix machine and i want to launch 2
processes.
proc #1 = render frames 1-10
proc #2 = render frames 11-20
os.fork os.execv os.wait are things that i have been reading.....
question: why do you os.spawnv?
Donn Cave wrote:
>
> Quoth Nickson Fong <nickson at centropolisfx.com>:
> | Can anyone show me a quick example on how to fork multiple processes on
> | a multiple cpu Irix machine. I know I need os.fork() and os.execvp() but
> | can't figure out how they work together.
>
> The reason it's so hard, is that there are so many different things
> you might want to do. One thing you might be missing is os.waitpid(),
> but it's hard to say.
>
> Just for something completely different, take a look at this:
>
> import os
>
> p = []
> p.append(os.spawnv(os.P_NOWAIT, '/bin/date', ('date',)))
> p.append(os.spawnv(os.P_NOWAIT, '/bin/date', ('date',)))
> p.append(os.spawnv(os.P_NOWAIT, '/bin/date', ('date',)))
>
> while p:
> for i in range(len(p)):
> pi, st = os.waitpid(p[i], os.WNOHANG)
> if pi == p[i]:
> del p[i]
> print 'pid', pi, 'status', st
> break
>
> Donn Cave, donn at oz.net
--
thanks
(:~~~ (:~~~ (:~~~ NO MORE EGGS ~~~:) ~~~:) ~~~:)
JUST
BADFROG
Tel : (310) 204-7300 Ext 120
Pager : 626-582-5459
Office Fax : 310-204 7301
nickson at centropolisfx.com
ubadfrog at yahoo.com
More information about the Python-list
mailing list