[Twisted-Python] catching adbapi 'thread' failures

Clark C. Evans cce at clarkevans.com
Wed Aug 18 22:48:24 EDT 2004


Howdy.  I'm stumped.  I thought I knew how failures work, but I
can't seem to stop a traceback from appearing with the following:

    from twisted.internet import reactor
    from twisted.python.util import println
    from twisted.enterprise import adbapi 
    dbpool = adbapi.ConnectionPool('pyPgSQL.PgSQL', database='testing')
    def interaction(trans):
        trans.execute('sqlerror')
        return trans.fetchall()[0][0] 
    def catch(failure):
        return "***" + failure.getErrorMessage().strip() + "***"
    def use_pool():
        d = dbpool.runInteraction(interaction)
        d.addErrback(catch)
        d.addCallback(println)
        d.addCallback(lambda _: reactor.stop())
    reactor.callLater(0, use_pool)
    reactor.run() 

Any help would be wonderful,

Clark

-- 
Clark C. Evans                      Prometheus Research, LLC.
                                    http://www.prometheusresearch.com/
    o                               office: +1.203.777.2550 
  ~/ ,                              mobile: +1.203.444.0557 
 //
((   Prometheus Research: Turning Data Into Knowledge
 \\  ,
   \/    - Research Exchange Database
   /\    - Survey & Assessment Technologies
   ` \   - Software Tools for Researchers
    ~ *




More information about the Twisted-Python mailing list