FuturesΒΆ
Starting from Python 3.2, concurrent.futures
provides a high-level
interface for asynchronously executing callables (for older versions there is a
Futures Backport)
The concurrent.futures.Future
class encapsulates the asynchronous
execution of a callable and Pizco has in-built support for it. Instead of
returning a Future, the Server will store it and notify the Proxy.
The proxy then returns a client-side Future connected to the original
server-side Future. The usage is just like normal Futures (there are just
that after all!):
from myproject import Robot
from pizco import Proxy
robot = Proxy('tcp://127.0.0.1:8000')
# Move is a method from robot that returns a Future
fut = robot.think('What do you get if you multiply six by nine?')
# Do something here
# fut is an instance of `Future`, therefore you can use the
# methods and properties described in the Python docs
answer = fut.result()
Note
Future.cancel() is not currently implemented.