[Twisted-web] Are twisted xmlrpc calls non-blocking?

Remi Cool mailinglists at smartology.nl
Thu Feb 8 06:31:27 CST 2007


Hello,

I need to be able to call xmlrpc methods on a remote xmlrpc server from
my twisted xmlrpc server.

I've created the following function in my service:

def xmlrpcCall(self, method, args, callback, callbackArgs=None,
callbackKeywords=None,
                                   errback=None, errbackArgs=None,
errbackKeywords=None):
    """Call xml-rpc method with args on the remote server"""

    # create proxy object and call the remote method with args
    p = xmlrpc.Proxy(self.url)
    d = p.callRemote(method, *args)
    # add callbacks
    d.addCallbacks(callback, errback, callbackArgs, callbackKeywords,
errbackArgs, errbackKeywords)
    return d

Is this call non-blocking?

I tend to think not, because when I call a method with a 5 sec delay
from a "runInteraction" thread, the thread returns when it handled the
call. This is how I prefer it in this case, but when I want to use the
xmlrpcCall method from a non "runInteraction" call, do I need to wrap it
up in a thread myself?

Like so:


from twisted.internet import threads

def xmlrpcAsyncCall(self, method, args, callback, callbackArgs=None,
callbackKeywords=None,
                                        errback=None, errbackArgs=None,
errbackKeywords=None):
    """Call xml-rpc method non-blocking with args on the remote server"""
   
    return threads.deferToThread(self.xmlrpcCall, method, args,
callback, callbackArgs=None, callbackKeywords=None,
                                                               
errback=None, errbackArgs=None, errbackKeywords=None)
   

Or can I just call xmlrpcCall, return the deferred and forget about it?

- Remi -



More information about the Twisted-web mailing list