[Twisted-Python] NetstringReceiver

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Mar 25 04:47:19 EDT 2010

On 08:36 am, albert.brandl at weiermayer.com wrote:
>On Thu, Mar 25, 2010 at 09:22:03AM +1100, Andrew Bennetts wrote:
>>I'm rather confused about why you're even asking this question. 
>>what API are you proposing as an alternative to the existing API 
>>is subclass NetstringReceiver and override stringReceived, and
>>stringReceived will be called for every netstring that is received, as
>>soon as it is received)?
>Never mind - I didn't understand the concept of deferreds ;-). When
>I read the code for FileSender, I thought it might be cool to have
>something similar for the NetstringReceiver. But in the case of
>FileSender, the delivery of a file is explicitly triggered by the
>My vague idea was to create a method beginNetstringReception that
>returns a Deferred. But since Deferred instances are not reusable,
>I'd have to call this method each time I wanted to receive a netstring,
>and this is obviously nonsense.

You might want a producer/consumer-based API.

More information about the Twisted-Python mailing list