summaryrefslogtreecommitdiffstats
path: root/module/FileDatabase.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-07 13:11:07 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-07 13:11:07 +0200
commit11c80f1d4985b21b5800b981428f7bf88fa9778b (patch)
treed1b66ae141541b3ff1b8e23139e7faa249c2cdde /module/FileDatabase.py
parentunrar ram check (diff)
downloadpyload-11c80f1d4985b21b5800b981428f7bf88fa9778b.tar.xz
recycle sqlite connection
Diffstat (limited to 'module/FileDatabase.py')
-rw-r--r--module/FileDatabase.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/module/FileDatabase.py b/module/FileDatabase.py
index 6e6537f38..4bcb63764 100644
--- a/module/FileDatabase.py
+++ b/module/FileDatabase.py
@@ -562,15 +562,17 @@ class FileDatabaseBackend(Thread):
self.c = self.conn.cursor()
#self.c.execute("PRAGMA synchronous = OFF")
self._createTables()
- self.c.close()
+
+ self.used = 0
while True:
try:
f, args, async = self.jobs.get()
+ self.used += 1
if f == "quit": return True
- self.c = self.conn.cursor()
+ if self.used > 300: #recycle connection
+ self.recycleConnection()
res = f(*args)
- self.c.close()
if not async: self.res.put(res)
except Exception, e:
#@TODO log etc
@@ -582,6 +584,17 @@ class FileDatabaseBackend(Thread):
self.syncSave()
self.jobs.put(("quit", "", 0))
+ def recycleConnection(self):
+ self.manager.core.log.debug("Recycle sqlite connection")
+ self.conn.commit()
+ self.c.close()
+ self.conn.close()
+ del self.c
+ del self.conn
+ self.conn = sqlite3.connect("files.db")
+ self.c = self.conn.cursor()
+ self.used = 0
+
def _checkVersion(self):
""" check db version and delete it if needed"""
if not exists("files.version"):