[Twisted-Python] difficulty in calling callLater from callback
Christopher Armstrong
radix at twistedmatrix.com
Wed Dec 10 11:47:03 MST 2003
Martin Waite wrote:
> dbpool = adbapi.ConnectionPool( "MySQLdb", host = 'localhost', user = 'martin', passwd = 'passwd', db = 'request' )
>
> def read_db_response(cursor):
> cursor.execute( "update 1" )
> cursor.execute( "update 2" )
> cursor.execute( "update 3" )
> return 1;
>
> def read_loop():
> dbpool.runInteraction( read_db_response ).addCallback( reactor.callLater, 1, read_loop )
This code will make cause reactor.callLater(1, 1, read_loop) to be
called, where the first `1' is the result of read_db_response.
You probably want
.addCallback(lambda r: reactor.callLater(1, read_loop))
or something.
--
Twisted | Christopher Armstrong: International Man of Twistery
Radix | Release Manager, Twisted Project
---------+ http://radix.twistedmatrix.com/
More information about the Twisted-Python
mailing list