[Python-ideas] [Value Returning Threard]

Chris Rebert pyideas at rebertia.com
Wed May 6 22:41:09 CEST 2009


On Wed, May 6, 2009 at 1:08 PM, yoav glazner <yoavglazner at gmail.com> wrote:
> Hi all,
> My Idea is to have a value returning Thread.
> I'll explain by example.
> <pycode>
> def foo():
>     time.sleep(20)
>     return 'bar'
> value = thread.startValueReturningThread(foo) #i need a better name for the
> function...)
> #here we do some work
> mg = moonGravity()
> mg.disable()
> #now we need the value that foo returned
> print value #this would be blocking untill foo is done!
> </pycode>
> This feature should provide a way to increase performance when possible with
> simple syntax.
> What do you think?

Sounds like you haven't heard of Futures -
http://en.wikipedia.org/wiki/Future_(programming)
One of probably many recipes for them in Python:
http://code.activestate.com/recipes/84317/

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-ideas mailing list