On Fri, 27 May 2005 22:28:06 +0300, Catalin Constantin <[EMAIL PROTECTED]> wrote: >Hi there, > >I have the following xmlrpc method: > >class FeederResource(xmlrpc.XMLRPC): > def __init__(self): > xmlrpc.XMLRPC.__init__(self) > self.feeder=Feeder() > > def xmlrpc_getList(self, id): > return self.feeder.get_urls(id) > >The thing is that the self.feeder.get_urls takes too long to execute >and while the request is running all the others are blocked. >I want that while it computes the result the other XML RPC methods to >be available.
The only answer here is to make get_urls() take less time. What is it doing? Is it blocking on network I/O? Querying a database? Prompting for user input? _It_ should be creating and returned a Deferred (and later calling it back with a result), most likely, since it is the long-running operation. > >I wanted to use deferrals but i found no viable example. > >Eg what i've tried to do: > def xmlrpc_getList(self, id): > log.debug("getList is here for id %s" % id) > d = defer.Deferred() > d.addCallback(self.feeder.get_urls) > return d Deferred don't make things asynchronous, cooperative, or non-blocking. They only make dealing with callbacks more convenient. If you add a blocking function as the callback to a Deferred, it will block the reactor just as effectively as if you called it yourself (bacause all that happens inside the Deferred is that the function gets called). > >My method feeder.get_urls is never called ! > In the above code, nothing ever "fires" the Deferred - calls .callback() on it - so, never having a result, it never bothers to invoke any of its callbacks. Deferred just hook results up to callbacks. Jp -- http://mail.python.org/mailman/listinfo/python-list