Re: [SQLObject] bug: connection/transaction leak?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-12-17 23:50:05
|
On Dec 17, 2003, at 3:24 PM, Guenther Starnberger wrote: > from SQLObject import * > import time > > class Account(SQLObject): > ___ name = StringCol(alternateID = True) > ___ password = StringCol() > > conn = PostgresConnection('user=zope dbname=WebspaceNG', autoCommit = > False) > > while 1: > ___ trans = conn.transaction() > ___ b = Account.new(name = "FOO" + str(time.time()), password = "bar", > connection = trans) > ___ trans.commit() > ___ raw_input() > - -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- > > if you run this code, with every iteration an additional connection > gets > opened to the postgresql server (until the max. connection limit is > reached & > postgresql refuses new connections). Hmm.. that shouldn't happen. Though looking at the code, I don't do a whole lot to return connections. The transaction should get garbage collected, and __del__ releases the connection, but I can imagine there'd be lots of reasons a transaction wouldn't get collected (though in this case it looks like it should be). Probably on commit()/rollback() the transaction should become invalid, and the connection should be returned. Or maybe you could run trans.begin() to revalidate it (at which point it'd grab another connection). -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |