[Twisted-Python] How to find out if exceptions are being raised in your errBack?

Tim Allen screwtape at froup.com
Wed Oct 14 06:26:27 MDT 2009


On Wed, Oct 14, 2009 at 07:43:41AM -0400, Steve Steiner (listsin) wrote:
> That's the thing about Twisted; sometimes it's hard to know whether
> the stuff that has been built into standard Python since Twisted
> 'rolled their own' is a superset, a subset, or a completely
> different beast.  Logging is a good case in point.  Since we're
> using Python's logging everywhere, I wasn't even sure whether there
> would be an advantage to learning Twisted's similar system.
> Twisted's trial is another example; we've just been using nose.
> Seems like there's always some little extra that makes the Twisted
> stuff worth knowing.

Most of the duplicate stuff in Twisted has the excuse of being written
before any alternatives were available, and usually having one or two
extra little integration features that current alternatives don't
provide.

A year or two ago I was planning a new project using Twisted, and (as
a reaction to the masses of horrible, legacy code at my employer) had
decreed that the project would use the Python stdlib wherever possible,
including logging and testing, and well-integrated third-party tools
where necessary.

First on the chopping block was the use of standard Python unit-tests
and nose. At the time, I don't believe it was possible to run TestCases
inheriting from twisted.trial.unittest.TestCase in anything besides
Trial - and you need to use trial's TestCase class if you want to do
anything with Deferreds, so nose and the standard unittest.TestCase had
to go.

Once I was using Trial, which automatically sets up Twisted's logging
system to log to a handy file for debugging purposes, I had to decide
what to do about logging - try to reroute Twisted's logging into the
Python logging system (which would mean doing something complicated for
tests), or just give up and use Twisted's logging everywhere. I opted
for the latter route as the path of least resistance (and because it
would be easier to set up with twistd later).

I believe nose does for Python logging what Trial does for Twisted
logging these days, and if nose can run Trial's TestCase subclasses, you
might just as well stick with what you're already using. There are
integration advantages to using all the Twisted goodies together, but
it's not nearly the same amazing quantum leap in understanding and
capability that Twisted's core provides.




More information about the Twisted-Python mailing list