[Twisted-Python] Patch for twisted.protocols.nntp

Matthias Urlichs smurf at smurf.noris.de
Mon Jun 23 06:51:40 EDT 2003


Hi, Jp Calderone wrote:

> Hmm, this is the only part of the patch I am unsure about.  The API
> seems a little too tuned to your use-case.  I think the way to go for
> this would be to have a Producer passed in and make the NNTP protocol a
> Consumer for that (in turn acting as a Producer for its transport
> object).  Would you be willing to make this change? (If you need an
> example of how this might work, check out smtp.py)

Hmm. Looking at the SMTP case, it needs refactoring in that the producer
isn't decoupled from the file object it ends up reading, thus I can't plug
a different kind of producer in there.

Looking further, there's a slightly-broken data-from-file producer in
doc/historic/2003/pycon/twisted-internet/twisted-internet.py ...

Anyway, I need NNTP to be a streaming protocol. With a Deferred, this is
easy -- each Deferred gets a callback which writes TAKETHIS plus the
message to the server (and queues the result code recognition), so these
can complete in any order, which is very nice. A producer interface would
instead have an arbitrary number of producers, all of which are active,
but as soon as the first one returns anything I have to temporarily
deactivate all the others. That sounds dangerous -- what if a producer
can't be paused? Then I need to buffer their data, too, which is no
different from the current case where the article data also end up in
memory.

-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf at smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
-- 
Man: I know how to please a woman.
Woman: Then please leave me alone.





More information about the Twisted-Python mailing list