[Twisted-Python] delay_connect problems in twisted.enterprise.adbapi
hoadley at gmail.com
Thu Dec 7 23:39:24 EST 2006
I'm having a problem using twisted.enterprise.adbapi.
The problem has to do with the 'delay_connect' option I send with my db
connection kwargs. I want to send sybase connection appname and hostname
info. The only way I can do this is using the delayed connect option.
I have the following standalone program example that works just fine:
vrdb = vr_db('billing_db', 'appname')
# vr_db just is a helper class for logical dbname -> db connection info
db_kwargs = vrdb.return_kwargs()
db_kwargs['cp_min'] = 1 # one thread min
db_kwargs['cp_max'] = 1 # one thread max = only one db connection
db_kwargs['cp_reconnect'] = 1 # reconnect if die
db_kwargs['cp_noisy'] = 1
db_kwargs['delay_connect'] = 1 # do the delayed connect
db_kwargs['cp_openfun'] = vrdb._vrdbOptions
dbpool = adbapi.ConnectionPool(vrdb.return_import_name(), **db_kwargs)
# _vrdbOptions adds the following two things to the connection
# conn.set_property (Sybase.CS_HOSTNAME, self.hostname)
# conn.set_property(Sybase.CS_APPNAME, self.appname)
a = storage(dbpool, d)
run does a sql query.
''' utility method if the script is called directly '''
self.get_campaign_info('id', 588103).addCallback( self.print_result
This works fine and dandy. With the hostname and appname showing up in my
sp_who optput (show's you who's logged in from where with what appname )
Now my problem is when I use the database connection part in
makeService(config) and pass a dbpool to a service, my service starts up
fine, but when
I have a database operation I get this:
2006/12/07 15:46:17 PST [-] [Failure instance: Traceback:
--- <exception caught here> ---
So I've reverted my code to pass db_kwargs['delay_connect'] = 0 and it's
working fine as long as I don't try the delay_connect. I'm hoping someone
has seen this before and can point me in the right direction. I'd really
like to have my appname and hostname show up on the db side.
I'm using twisted, sybase 12.5, and the most recent Sybase module. The
only difference is the way I'm connecting is one program is a tap created
from mktap and the other a standalone script.
>>> import Sybase
>>> import twisted
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python