Hello,<br><br>I'm having a problem using twisted.enterprise.adbapi.<br><br>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.<br> <div id="mb_0"> <br>I have the following standalone program example that works just fine:<br><br>vrdb = vr_db('billing_db', 'appname')
<br># vr_db just is a helper class for logical dbname -> db connection info<br><br>db_kwargs = vrdb.return_kwargs() <br>
<br>db_kwargs['cp_min'] = 1 # one thread min<br>db_kwargs['cp_max'] = 1 # one thread max = only one db connection<br>db_kwargs['cp_reconnect'] = 1 # reconnect if die<br>db_kwargs['cp_noisy'] = 1<br>db_kwargs['delay_connect'] = 1 # do the delayed connect
<br>db_kwargs['cp_openfun'] = vrdb._vrdbOptions<br><br>print db_kwargs<br>dbpool = adbapi.ConnectionPool(vrdb.return_import_name(), **db_kwargs)<br><br># _vrdbOptions adds the following two things to the connection<br>#
conn.set_property
(Sybase.CS_HOSTNAME, self.hostname) <br>
# conn.set_property(Sybase.CS_APPNAME, self.appname) <br>
<br>a = storage(dbpool, d)<br>a.run()<br>reactor.run()<br><br>run does a sql query.<br><br> def run(self):<br> ''' utility method if the script is called directly '''<br> self.get_campaign_info('id', 588103).addCallback(
self.print_result).addErrback(self.error_happened)<br><br>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
) <br><br>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 <br>I have a database operation I get this:<br> <br><br>2006/12/07 15:46:17 PST [-] [Failure instance: Traceback:
twisted.enterprise.adbapi.ConnectionLost:<br> /usr/lib/python2.4/threading.py:422:run<br> /usr/lib/python2.4/site-packages/twisted/python/threadpool.py:148:_worker<br> /usr/lib/python2.4/site-packages/twisted/python/context.py:59:callWithContext
<br> /usr/lib/python2.4/site-packages/twisted/python/context.py:37:callWithContext<br> --- <exception caught here> ---<br> /usr/lib/python2.4/site-packages/twisted/internet/threads.py:25:_putResultInDeferred
<br> /usr/lib/python2.4/site-packages/twisted/enterprise/adbapi.py:379:_runInteraction<br> /usr/lib/python2.4/site-packages/twisted/enterprise/adbapi.py:64:rollback<br> ]<br><br><br>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.
<br><br>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.<br><br>>>> import Sybase
<br>>>> Sybase.__version__<br>'0.37'<br>>>> import twisted<br>>>> twisted.__version__<br>'2.4.0'<br><br>Thanks<br><br>-rob<br><span class="sg"></span></div>