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

Steve Steiner (listsin) listsin at integrateddevcorp.com
Wed Oct 14 09:05:00 EDT 2009

On Oct 14, 2009, at 8:26 AM, Tim Allen wrote:

> 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.

Yes, that extra little integration feature sometimes makes a huge  
difference.  But, as you said, being as much of Twisted's stuff  
predates the 'equivalent' stdlib stuff, it's hard to know where the  
leverage is going to be.

For example, Python's standard logging has the advantage of being able  
to generate many different types of logging outputs (e.g.  
logging.handlers.SMTPHandler) whereas Twisted's is better integrated  
with Twisted but is missing many of those types of things.

Trial and deferreds vs. nose and its integration with e.g. coverage...

It's hard to know when to use which and, as you said, we want to use  
standard library stuff wherever possible.

> 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'm working out a blended method having a PythonLoggingObserver that  
relay's Twisted's log messages to Python standard logging, as per  
Glyph's suggestion.  That way we don't have to mangle all of our  
working logging code, bug special notifications we can reroute to a  
special "Twisted Messages" file that we know to keep an eye on.

> 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.

Again, we'll probably end up with a blended approach since we use nose  
for coverage and profiling integration as well.

We are having fun now, right?


More information about the Twisted-Python mailing list