[Twisted-Python] PullProducer appreciation, lack thereof.
Kevin Turner
acapnotic at twistedmatrix.com
Wed Apr 2 12:25:04 EST 2003
On Mon, 2003-03-24 at 14:29, radix CVS wrote:
> class IPullProducer(IProducer):
> """A pull producer, also known as a non-streaming producer, is
> expected to produce data each time resumeProducing() is called.
> """
> def resumeProducing(self):
> """Resume producing data.
> This tells a producer to re-add itself to the main loop and produce
> more data for its consumer."""
Usage and behaviour of a PullProducer isn't clear to me. Does
PullProducer.resumeProducing mean that it should call consumer.write
exactly once? Or is the amount of times consumer.write will be called
undefined or context-dependent but merely guaranteed to be finite?
A PushProducer delivers an undefined quantity of data to consumer.write
some unknown time after resumeProducing is called. A PullProducer
delivers an undefined quantity of data to consumer.write some unknown
time after resumeProducing is called. So why two interfaces? Why don't
pulling consumers just use pauseProducing upon getting a .write?[1]
Then we can ditch one of the interfaces and the 'streaming' argument to
registerProducer and the conditionals that go with it...
If it is a different interface, can we give the method a different
name? I think it strange that you call "resume" on these when producing
has never been "paused". And that "resume" in this case does not signal
a return to an ongoing process from which it has been interrupted, but
is a single request for a discrete amount of data. A name beginning
with "get" or "next" seems more fitting.
- Kevin
[1] "...just use pauseProducing upon getting a write()?": One answer to
that could be "it's more message traffic"; every write in a
pull-producer implemented on PushProducer this way would involve
p.resume();c.write();p.pause() as opposed to just p.resume();c.write().
But that alone doesn't convince me the interface confusion is worth it.
--
The moon is new, 0.3% illuminated, 0.5 days old.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030402/0250a1e3/attachment.pgp
More information about the Twisted-Python
mailing list