This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients giampaolo.rodola, josiah.carlson, josiahcarlson, nirs, pitrou, r.david.murray
Date 2010-08-31.22:23:01
SpamBayes Score 5.841584e-10
Marked as misclassified No
Message-id <1283293378.3176.4.camel@localhost.localdomain>
In-reply-to <1283282337.49.0.734756619317.issue9693@psf.upfronthosting.co.za>
Content
> > - why override __bool__??
> 
> I did that for performance.
> Considering that initiate_send() method is called many times, and that
> it is almost always used to send data rather than firing functions I
> wanted to avoid to call isinstance(first, _Callable) (or
> hasattr(first,  '__call__')) on every loop.

This looks hackish... You should at least make the purpose very clear in
comments to the code.
Also, really, isinstance(..., _Callable) is better than the hasattr()
call, IMO.

> The API follows the exact same approach as push(),
> push_with_producer() and close_when_done() methods.
> It adds "something" to a fifo and that "something" will be processed
> (called) only when the previous producers are exhausted, respecting
> the order of what has been "pushed" first and later.
> This is different than a deferred.

Well, a deferred would be fired when a given piece of data has been sent
(or failed to send, in which case the errback would be run rather than
the callback). This is in the end equivalent, since I suppose the send
queue is sequential and never gets reordered.

In any case, I guess it's too late to change the overall design. I just
wanted to point out that the Deferred concept unified a lot of use cases
under a simple convenient abstraction. It avoids having to define ad hoc
methods such as push_callable().

> Something similar to Twisted deferreds is this:
> http://bugs.python.org/issue1641

This has nothing to do with Deferreds actually :)
History
Date User Action Args
2010-08-31 22:23:04pitrousetrecipients: + pitrou, josiahcarlson, nirs, giampaolo.rodola, josiah.carlson, r.david.murray
2010-08-31 22:23:02pitroulinkissue9693 messages
2010-08-31 22:23:01pitroucreate