[Tutor] threading not working how about fork?
Classification: UNCLASSIFIED Caveat (s): FOUO Thanks for the help and I am looking into the pyprocessing but threading is causing too many headaches (I may have to rewrite things). Lets say I have something as simple as below: def takeTime(a): print Started %s % a time.sleep(10) print Ended %s % a for each in [1,2,3,4,5]: pid = os.fork() takeTime(each) Each time the function is called it waits 10 seconds. And if I run it as above it does the first and waits 10 seconds then the second and waits ten seconds...etc. Wow could I get it to run through all 5 forks without waiting for the previous one to complete? That was all five would be done in about 10 seconds. This is simpler than my real problem but I can not even figure this one out. Thanks for the help. John Ertl Meteorologist FNMOC 7 Grace Hopper Ave. Monterey, CA 93943 (831) 656-5704 [EMAIL PROTECTED] Classification: UNCLASSIFIED Caveat (s): FOUO ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] threading not working how about fork?
On Wed, Oct 22, 2008 at 5:44 PM, Ertl, John C CIV 63134 [EMAIL PROTECTED] wrote: Classification: UNCLASSIFIED Caveat (s): FOUO ?? Thanks for the help and I am looking into the pyprocessing but threading is causing too many headaches (I may have to rewrite things). Lets say I have something as simple as below: def takeTime(a): print Started %s % a time.sleep(10) print Ended %s % a for each in [1,2,3,4,5]: pid = os.fork() takeTime(each) Each time the function is called it waits 10 seconds. And if I run it as above it does the first and waits 10 seconds then the second and waits ten seconds...etc. You are calling takeTime() from both the parent and child process, and you are spawning additional processes from the child process as well. Try if os.fork(): takeTime(each) break Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor