[Twisted-Python] how to stop dataReceived while waiting a deferred to fire?

glyph at divmod.com glyph at divmod.com
Mon Feb 21 15:47:57 EST 2005

On Mon, 21 Feb 2005 18:46:18 +0100, Andrea Arcangeli <andrea at cpushare.com> wrote:

> Ok here we go, I even found a severe bug in the linereceiver code and I
> fixed it as well. The bug in linereceiver happens like this:

Any chance that you could include some unit tests for the behavior you're expecting?  I think it might need to be fixed a different way.  For example:

> Index: Twisted/twisted/protocols/basic.py
> ===================================================================
> --- Twisted/twisted/protocols/basic.py	(revision 13001)
> +++ Twisted/twisted/protocols/basic.py	(working copy)
>          self.recvd = self.recvd + recd
> -        while len(self.recvd) > 1:
> +        while len(self.recvd) > 1 and not self.paused:

This seems like it could lead to some unpleasantly large (i.e. quadratic-time concatenation) buffers strings being left around if you pause one of these receivers and then forget to unpause it, or even just if your peer happens to be sending data very rapidly.

More information about the Twisted-Python mailing list