Add finish() method to twisted.interfaces.IConsumer
|Reported by:||Ying Li||Owned by:|
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.