speed up new card fetching, add a text factory arg to the db, fix stopMplayer()

This commit is contained in:
Damien Elmes 2011-03-14 17:30:55 +09:00
parent ab281d0bc6
commit 174b13f7df
3 changed files with 5 additions and 3 deletions

View file

@ -15,9 +15,11 @@ from anki.hooks import runHook
#FIXME: do we need the dbFinished hook?
class DB(object):
def __init__(self, path, level="EXCLUSIVE"):
def __init__(self, path, level="EXCLUSIVE", text=None):
self._db = sqlite.connect(
path, timeout=0, isolation_level=level)
if text:
self._db.text_factory = text
self._path = path
self.echo = os.environ.get("DBECHO")

View file

@ -101,7 +101,7 @@ class Scheduler(object):
else:
self.newQueue = self.db.all("""
select id, due from cards where
queue = 2 %s order by due, id limit %d""" % (self.groupLimit('new'),
queue = 2 %s order by due limit %d""" % (self.groupLimit('new'),
lim))
self.newQueue.reverse()
self.newCount = len(self.newQueue)

View file

@ -233,7 +233,7 @@ def ensureMplayerThreads():
mplayerReader.daemon = True
mplayerReader.start()
def stopMplayer():
def stopMplayer(*args):
if not mplayerManager:
return
mplayerManager.kill()