Are twisted xmlrpc calls non-blocking?
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 -
On 2/8/07, Remi Cool <mailinglists@smartology.nl> wrote:
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:
Is this call non-blocking?
It is non-blocking. If it returns a Deferred it is unlikely to be blocking, unless the author didn't understand what the point of Deferreds are :) Remember: Twisted tries very hard to never require you to do any kind of thread work. Also remember, just in case: The only Twisted API that is thread safe is reactor.callFromThread. -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/
participants (2)
-
Christopher Armstrong -
Remi Cool