[Twisted-Python] A C/S Application over Internet
phil at bubblehouse.org
Thu Aug 27 12:03:27 EDT 2009
On Aug 27, 2009, at 10:57 AM, 陶艺夫 wrote:
> Thank you, Phil.
> Pyro has many examples, so I can understand it easily. I know
> Twisted is great. I think your "switching" must mean something :) .
> So I decide to use twisted PB.
I also remembered one thing that I found was extremely useful when
dealing with a GUI app that communicates over PB. Since PB assumes
every remote method call will take an arbitrary amount of time to
execute, you can delay the response from the client as long as you need.
For example, let's say the server sends a block of text to the client
for editing. Your client-side function can create a Deferred, hold a
reference to it somewhere, and return that from the client function.
PB won't actually send a response until you invoke the callback()
method on that Deferred, so you can pop open a GUI window, let the
user edit the text (or just sit there staring at it for an hour), and
then trigger the callback when the user hits 'Save'.
Very useful, although I wrote some incredibly stupid code to emulate
this long before I realized how easy it was ;-)
More information about the Twisted-Python