Thursday, December 3, 2009

Twisted Annoyances

While Twisted is generally an excellent network library, it certainly has its quirks.
  • Exception Trapping: by default, the reactor will trap all exceptions. See ReactorBase.runUntilCurrent for the code that implements this horrible behavior. This breaks intuitions most developers have for how exceptions are supposed to work. For example, the python tutorial says:
    The last except clause may omit the exception name(s), to serve as a wildcard. Use this with extreme caution, since it is easy to mask a real programming error in this way!
    Twisted does an excellent job of masking real programming errors. I'm surprised that there is no option to turn off this behavior.
  • callFromThread: calling a reactor method (e.g. protocol.writeData) from a non-reactor thread doesn't work without wrapping it with this method.

No comments:

Post a Comment