[Twisted-Python] Looking for an answer...
![](https://secure.gravatar.com/avatar/96a6fa70caad11789ce45b7096860447.jpg?s=120&d=mm&r=g)
I have programmed very traditional systems passed on fork and pthreads and have used state machine systems. Last year I started working with Twisted Matrix. Each has their appropriate application. I started thinking about how to implement the following in Twisted, and realized I don't know if it is possible. I thought I would ask the list to find out if someone can come up with an answer. Suppose I have a sequence of instructions, some of which can take a long time. For example in a non-Twisted Matrix system I would do: ....do some computation.... proxy = xmlrpc.Proxy("http://....") proxy.CallRemote(....) ... take the results of the CallRemote and use them... In this example I assume CallRemote() only returns a result when it has completed. In the Twisted Matrix system I would do something like: ...do some computation.... proxy = twisted.web.xmlrpc.Proxy("http://...") defer = proxy.CallRemote(...) defer.addErrback(fcs_storeErr,...) defer.addCallback(fcs_storeDone,...) And I would define fcs_StoreErr() and fcs_storeDone(). In fcs_storeDone() I would take the results from the CallRemote() and process them. My question is easy (the answer might be hard): Can I emulate the non-Twisted example in the Twisted Matrix system. In other words can I create something like CallRemote() which returns only there is a result to process and get away from having to explicitly use a defer? Peace, Chaz
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Sun, 2007-04-29 at 11:36 -0400, Chaz. wrote:
You might want to look at twisted.internet.defer.inlineCallbacks. -- Itamar Shtull-Trauring http://itamarst.org
![](https://secure.gravatar.com/avatar/d7875f8cfd8ba9262bfff2bf6f6f9b35.jpg?s=120&d=mm&r=g)
On Sun, 2007-04-29 at 11:36 -0400, Chaz. wrote:
You might want to look at twisted.internet.defer.inlineCallbacks. -- Itamar Shtull-Trauring http://itamarst.org
participants (2)
-
Chaz.
-
Itamar Shtull-Trauring