IronPython-0.6 is now available!

Valentino Volonghi aka Dialtone dialton3#NOSPAM.JJJJKIKK at
Sun Aug 1 14:21:02 CEST 2004

On Sat, 31 Jul 2004 13:37:35 +1000, Derek Thomson wrote:

> So, why can't it just be basically:
> object.echo("hello network")
> ... as it is in CORBA and (other) XML-RPC and SOAP toolkits I've used.

I don't think that calling:

object.echo("hello network") 
instead of
object.callRemote('echo', 'hello network')

is making any difference at all... Actually the CORBA author is evalutaing
twisted for his next needs (IIRC). Add this to the fact that doing
callRemote() you are not moving any objects around, Perspective Broker
let's you copy objects from the remote side to the client side and then
you would be able to call

object.echo('hello network')

for instance.

> I also have a problem with the insistence on the use of asynchronous
> callbacks. In order to use the result of the RPC call later in the
> main flow of my code, I have to somehow block in the main thread for
> the the result to be returned from the server via the callback - this
> is something that can be done for me, and is handled simply and
> transparently in other RPC toolkits/mechanisms I've used.

Clearly you do not know deferreds. Twisted won't wait for your response
blocking the whole thread. It will just send the request and when the
response comes back it will call your code for you.

> I'll try to characterize this with a simple example. How would I write
> something like this, where I have three distributed objects:
> i = an_object.get_value()
> j = another_object.get_value()
> k = yet_another_object.combine(i, j)
> ... and now finally use "k" in my code?

You will use it in a callback.

Obviously if you don't like callbacks you won't like twisted, but this
doesn't make RPC with twisted primitive. I would say that you simply don't
like the way you write code with twisted.

> I could be missing something, but isn't that going to turn into a mess
> of dependant callbacks in Twisted? Aren't I going to have to write a
> whole lot of code that blocks until the results come back? I don't
> mean this as a challenge or a judgement anything, I'd honestly like to
> know - I would like to look further into Twisted but was pretty much
> put off by this issue right from the start.

Code won't block. You should read how deferreds work (note: they are not
making your blocking code into non-blocking code, but they will be waiting
in the background for an answer to a request, without blocking everything).

BTW Twisted provides 2 different ways of making you blocking code

You can use deferToThread, if you have a very long atomic operation (like
querying a remote database), or you can divide your very-big-function into
many different steps and call each other with 
reactor.callLater(0, nextStep)
Which makes the call happen the next cicle in the reactor (so to allow the
reactor to handle some requests in the meantime).

Usually for third party modules with blocking logic the most used choice
is deferToThread. But I suggest you reading the documentation from which is a lot more helpful.


Valentino Volonghi aka Dialtone
Linux User #310274, Proud Gentoo User
Home Page:

More information about the Python-list mailing list