newbie threading question

Lee Harr missive at frontiernet.net
Fri Jul 27 00:17:10 CEST 2001


On Thu, 26 Jul 2001 05:33:30 GMT, douglas savitsky <dsavitsk at e-coli.net> wrote:
> this is a slightly modified version of a response from the other day using
> win32process.beginthreadex() instead of thread ...
> 
> # ------------------------------
> import win32process
> import time
> 
> def Func(id, numSecs, incBy):
>     val = 0
>     while 1:
>         print id, val
>         val = val + incBy
>         time.sleep(numSecs)
>         if val > 10: break
>     return 1
> 
> if __name__ == '__main__':
>     a = win32process.beginthreadex(None, 0, Func, ("First thread", 1, 2), 1)
>     b = win32process.beginthreadex(None, 0, Func, ("Second thread", 1, 3),
> 1)
> # ------------------------------
> 
> is there anyway to capture the return value?  i need to run several
> simultaneous large computations, but i would like to capture the returns ...
> i think?  do i not? can anyone give some suggestions on where to look?
> 


Well... hmmm.

Both threads are printing to standard out, right?

You could have them preface their "return value" with a tag
and print it out before returning.

RT1: 1
RT2: 0
...

Then you could parse the output.

Seems like a good use for a pipe. Possible on win32? Don't know!




More information about the Python-list mailing list