[Twisted-web] Mysterious behavior w/ XMLRPC plus adbapi

Sean Scoggins seanscoggins at gmail.com
Mon May 22 19:24:36 CDT 2006


Hello from a new list member!  I'm evaluating Twisted for use in my
company's product, and I'm currently stuck on a problem that I don't know
how to debug.

I am creating an XMLRPC server that uses twisted.enterprise.adbapi to query
a database.  The symptom I've seeing is that the *third* call to an xmlrpc
method that queries the database delays for some time (a minute or so)
before returning with the correct results.  The first two calls always
return very quickly.  Calls after the third one usually return quickly as
well.

I've narrowed down the code as far as I can, and I'm not sure what to check
next.  Any help would be appreciated.  Here's what I've found so far
(complete code is at the bottom of the email):

1) Not using the XMLRPC server, just using reactor.callLater() to run the
query, then calling callLater again in the callback results in the query
getting run over and over and I never see a delay.  So I suspected the
XMLRPC server code.

2) Calling XMLRPC methods that don't use the dbpool always return quickly.
So I suspected the adbapi code.

3) Changing the cp_min argument to ConnectionPool's constructor can change
the behavior - making it larger than 3 results in the third call being
delayed, then the fourth call getting error 8002 back from the server.

4) I've tried adodbapi as well as the eval version of mxODBC just to make
sure it wasn't the db driver - the behavior is identical in both cases.

Any ideas?  Thanks in advance,
Sean

---
from twisted.internet import reactor
from twisted.web import xmlrpc
from twisted.enterprise import adbapi

class ReportRunner(xmlrpc.XMLRPC):
    def __init__(self):
        self.dbpool = adbapi.ConnectionPool("mx.ODBC.Windows",
"dsn","user","pwd")

    def xmlrpc_test(self):
        return self.dbpool.runQuery("select 1")

    def xmlrpc_quit(self):
        reactor.callLater(1, reactor.stop)
        return "OK"

def main():
    from twisted.web import server
    r = ReportRunner()
    reactor.listenTCP(7080, server.Site(r))
    reactor.run()


if __name__ == '__main__':
    main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20060522/252d5eca/attachment.htm


More information about the Twisted-web mailing list