[Twisted-Python] Re: runInteraction example

Craig H. Anderson craig at coot.net
Mon Jun 14 17:45:45 MDT 2004


Thanks for the reply.  Since I posted I found
that there is a problem with using the adodbapi
package.  I will start another thread about this. 

Dave Peticolas writes: 

> 
> 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'))
>     d.addCallback(stop) 
> 
> reactor.callLater(0, use_pool)
> reactor.run() 
> 
> 
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python 
> 
 




More information about the Twisted-Python mailing list