Wednesday, March 9, 2011

Twisted: Beware: Returning a Value from dataReceived

We just lost approximately 10-man-hours to undocumented behavior of Twisted. If you return a True truth value from your dataReceived function (after it is called by the reactor), the reactor will destroy your protocol, and close the corresponding connection. Fortunately, this behavior is recognized as a bug and a deprecation warning will be likely be issued with this behavior in the 11.0 release. But, since many of us are stuck with Twisted 10.2 or earlier for months, if not years, to come, it's good to be aware of this issue.