[Twisted-Python] Looking for some advice debugging issue with transport.write calls

Brian Costlow brian.costlow at gmail.com
Mon Apr 27 23:26:15 MDT 2015


On Mon, Apr 27, 2015 at 8:26 PM, Itamar Turner-Trauring <itamar at itamarst.org
> wrote:

> self.in_send_message seems like a potential source of bugs (can't see it
> being set to False on all branches here) and is also likely unnecessary.
>

self.in_send_message is redundant with self.waiting_id, which was added
later, and will be refactored out next iteration.

But, after a message removed from the queue and sent, we can't send another
until either we get an ack message back, or the timeout fires. Those bits
of code omitted here, are what resets self.in_send_message back to False.
(Or eventually, self.waiting_id to None).

Suggestions on a better way to do this are most welcome. I thought about
only having check_for_send push itself back on the reactor loop if the
queue is empty, and having the ack and/or timeout code fire check_for_send
in other cases, instead of setting the variable. Not sure that's terribly
simpler, though.
>
> General advice:
>
> 1. Simplify, simplify, simplify.
>
> 2. Unit tests (see
> https://twistedmatrix.com/documents/current/core/howto/trial.html).
>

There actually is a test around this, although ugly, as it has to simulate
the protocol and the factory's queue. It passes. This also works when we
run integration tests with some 3rd party open source apps, but breaks in
production at one location.

#1 well taken though, I should break check_for_send up and make it easier
to write simple tests.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20150428/8085e6f4/attachment-0002.html>


More information about the Twisted-Python mailing list