a couple more cursor closings

This commit is contained in:
Adrian Sampson 2011-05-05 18:26:29 -07:00
parent 8341dee3ab
commit e5e11503ad
2 changed files with 9 additions and 4 deletions

View file

@ -959,6 +959,8 @@ class Library(BaseLibrary):
return it.next()
except StopIteration:
return None
finally:
it.close()
def get_album(self, item_or_id):
"""Given an album ID or an item associated with an album,
@ -976,8 +978,10 @@ class Library(BaseLibrary):
'SELECT * FROM albums WHERE id=?',
(album_id,)
)
record = c.fetchone()
c.close()
try:
record = c.fetchone()
finally:
c.close()
if record:
return Album(self, dict(record))

View file

@ -889,8 +889,9 @@ class Server(BaseServer):
statement = 'SELECT COUNT(DISTINCT artist), ' \
'COUNT(DISTINCT album) FROM items'
c = self.lib.conn.cursor()
result = c.execute(statement).fetchone()
c = self.lib.conn.execute(statement)
result = c.fetchone()
c.close()
artists, albums = result[0], result[1]
yield (u'artists: ' + unicode(artists),