Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: [Twisted-Python] xmlrpc deferred

Thread Tools

Re: [Twisted-Python] xmlrpc deferred

Jp Calderone
Posts: n/a
On Fri, 27 May 2005 22:28:06 +0300, Catalin Constantin <(E-Mail Removed)> 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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deferred Evaluation in Recursive Expressions? Python 8 05-10-2006 05:53 AM
maxplusII error: a deferred constant declaration without a full declaration is not supported Noah VHDL 5 04-07-2006 02:34 PM
Deferred packets on a full duplex link Ken Stumpf Cisco 5 09-26-2005 09:22 PM
deferred decorator Bryan Python 3 12-09-2004 09:34 AM
Re: xmlrpc, httplib and SSL (HTTP 1.1 XMLRPC client) Etienne Posthumus Python 1 04-01-2004 05:13 PM