I am working on a Python concurrency infrastructure (I know, YACF) and would like to be able to return variables as futures, but without the user noticing this.
Now I am doing:
x = someAsyncMethod(args)
print "Return value is %d" % x.get_value( )
Since the method returns a Future object, but I would like to:
x = someAsyncMethod(args)
print "Return value is %d" % x
But still .get_value () from x matters. Therefore, I would like to proxy Python objects, including int. Something like __get__, but so if ProxyInt was a proxy for int, and I did:
x = ProxyInt(10)
print x
or
n = x
My "__get__" method will be called and do the magic before doing "return 10"
source
share