Hi Matej,

mato konecny wrote:
> Hi all,
> 
> First of all, I am not Twisted nor Python expert, so this question is
> maybe trivial. The question is related to an IMDB plugin.
> Anyway, I created a layer between my resource provider (that does some
> HTTTP operations and returns deferred) and the controllers. This is
> mainly for caching and convenience purposes and works quite OK. What I
> do, I create a singleton of my extra layer (retriever) which then
> internally calls resource provider. The problem is that if user has for
> example 20 movies in library, that means 20 defereds are fired almost
> instantly, resulting in 20 HTTP GETs (and some more because of the
> resource provider implementation).
> This is also bit annoying for user because then the responses to the GET
> requests arrive asynchronously and therefore I want to implement a
> queueing mechanism. I got some inspiration from MediaScanner, so create
> an object, in that one create deferred and put this in the queue and
> return created deferred. When the time comes, the object is taken out of
> the queue, processed and (here comes my problem) how can I signal the
> original callee that "it's finished".
> Maybe this needs some code example, probably it's bit too long to post
> it here, but I can add it later if it clarifies what I am talking about :)

What I don't really get is why you would want to queue requests and make
an asynchronous process synchronous. Elisa uses asynchrony to provide
the user a responsive UI and it is perfectly fine to receive delayed
answers when populating some part of the UI. Just make sure you display
some default image e.g. while waiting for the answer.

As far as I understand, you don't need a queuing mechanism, just to
connect callbacks to your deferreds that will populate your UI (or take
whatever action needed) when fired.

If I misunderstood your problem don't hesitate to ask again, maybe with
a simple use case and/or code snippets.

> Cheers,
> Matej

Cheers,

Olivier

Reply via email to