Opened 4 years ago

Closed 4 years ago

#4554 enhancement closed invalid (invalid)

Add finish() method to twisted.interfaces.IConsumer

Reported by: cyli Owned by:
Priority: normal Milestone:
Component: core Keywords: question
Cc: Branch:
Author: Launchpad Bug:

Description

IConsumer should, in addition to unregisterProducer, contain a finish() method.

While unregisterProducer() means "I will not produce any more data for you, but someone else may", finish() would mean "Nobody will ever produce any more data for you, please terminate your consumption and clean up".

This could map to meaningful operations on various consumers. For example, a Process is a consumer that can map "finish" to closeChildFD(0) (loseConnection also closes other process pipes and is not the correct operation when consumption is complete).

Then, to map this extended Consumer to a Protocol via an adapter (as is done in twisted/internet/protocol.py) you would map finish to writeConnectionLost.

A Process would map (as it does today) all consumer methods to childfd(0). Being a FileDescriptor, it would map finish() to a loseWriteConnection, which in the case of a ProcessWriter would convert to a loseConnection.

Change History (3)

comment:1 Changed 4 years ago by cyli

This was pulled from a comment in #2661 - please either remove the question keyword (or otherwise indicate that this is a valid point) or close as won't-fix.

comment:2 Changed 4 years ago by exarkun

  • Resolution set to invalid
  • Status changed from new to closed

There's no clear reason for this. The producer/consumer interface is about passing around buffer events (buffer full, buffer empty). You pretty much always need some more protocol logic beyond that to do anything useful. So I don't see the value in forcing every existing IConsumer implementation to gain a new method, nor in forcing every IProducer implementation to deal with the two different variations of IConsumer for the next N years.

Besides, if this made sense, then IFinishableConsumer would make sense, and we'd be deprecating IConsumer instead (#2661).

comment:3 Changed 4 years ago by <automation>

  • Owner glyph deleted
Note: See TracTickets for help on using tickets.