[Twisted-Python] runInteraction example

Dave Peticolas dave at krondo.com
Mon Jun 14 19:41:49 EDT 2004

Looks like the list didn't like my attachment. Here is the runInteraction
example inline:

import sys

from twisted.internet import reactor
from twisted.enterprise import adbapi

dbpool = adbapi.ConnectionPool('DCOracle2', YOURLOGINHERE)

def interaction(trans, num, div):
    trans.execute('select %d/%d from dual' % (num, div))
    print trans.description
    return trans.fetchall()[0][0]

def stop(_): reactor.stop()

def use_pool():
    d = dbpool.runInteraction(interaction, num=10, div=2)
    d.addCallback(lambda res: sys.stdout.write(str(res)+'n'))

reactor.callLater(0, use_pool)

More information about the Twisted-Python mailing list