Hello list, I'm running into a problem when running a small web app in webpy with sqlobject. The app is a REST interface which handles URLs such as:
GET /pkgdb/rest/srv4/7793c4a5ecd6494b25d475632618e44c/pkg-stats/ HTTP/1.1 and PUT /releases/catalogs/unstable/i386/SunOS5.9/7793c4a5ecd6494b25d475632618e44c/ HTTP/1.1 When called with PUT, it does a few checks and inserts a row into a table. When the application runs, it initially works for a minute or two, but eventually gets into state in which it always fails with this exception: Traceback (most recent call last): File "/opt/csw/lib/python/site-packages/web/application.py", line 239, in process return self.handle() File "/opt/csw/lib/python/site-packages/web/application.py", line 230, in handle return self._delegate(fn, self.fvars, args) File "/opt/csw/lib/python/site-packages/web/application.py", line 420, in _delegate return handle_class(cls) File "/opt/csw/lib/python/site-packages/web/application.py", line 396, in handle_class return tocall(*args) File "/home/maciej/src/opencsw-gar/lib/web/releases_web.py", line 187, in PUT srv4 = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne() File "/opt/csw/lib/python/site-packages/sqlobject/sresults.py", line 277, in getOne results = list(self) File "/opt/csw/lib/python/site-packages/sqlobject/sresults.py", line 181, in __iter__ return iter(list(self.lazyIter())) File "/opt/csw/lib/python/site-packages/sqlobject/sresults.py", line 189, in lazyIter return conn.iterSelect(self) File "/opt/csw/lib/python/site-packages/sqlobject/dbconnection.py", line 471, in iterSelect return select.IterationClass(self, self.getConnection(), File "/opt/csw/lib/python/site-packages/sqlobject/dbconnection.py", line 336, in getConnection conn = self.makeConnection() File "/opt/csw/lib/python/site-packages/sqlobject/mysql/mysqlconnection.py", line 71, in makeConnection conn.ping(True) # Attempt to reconnect. This setting is persistent. ProgrammingError: (2014, "Commands out of sync; you can't run this command now") This state persists until I restart the web server ‒ any query which requires a connection to the database will fail with the same error, visible as 500 Internal Server Error on the HTTP client side. From reading the mysqlconnection.py source code, this function only intends to throw SqlObject exceptions, and not exceptions specific to the database engine. I'm guessing that it isn't expected that conn.ping() could throw an exception? The failing function in my app starts here: https://sourceforge.net/apps/trac/gar/browser/csw/mgar/gar/v2/lib/web/releases_web.py#L143 Does it look like a problem with my application, or does it look like something that should be handled on the SqlObject side? Or should I check for the state of the connection at the start of this function? Versions of software I'm using: SqlObject 1.3.2 Python 2.6.8 MySQL Server 5.5.30 MySQLdb python module 1.2.3 Apache 2.2.22 Oracle Solaris 10 9/10 s10x_u9wos_14a X86 Maciej ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss