summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-09-11 08:35:41 +0200
committerHelmut Grohne <helmut@subdivi.de>2013-09-11 08:35:41 +0200
commit786c4f93ea318a3c22479f80531594435fb036c3 (patch)
treef6522faeb72908c5e8cc61c1ddc2d6225dfb918e
parentca65a78a9ace0aeb2565df0da171727c04c33970 (diff)
downloaddebian-dedup-786c4f93ea318a3c22479f80531594435fb036c3.tar.gz
webapp: open cursors less often
On the main instance opening cursors equals initiating a connection. Unfortunately sqlite3.Connection.close does not close filedescriptors. So just open less cursors to leak filedescriptors less often.
-rwxr-xr-xwebapp.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/webapp.py b/webapp.py
index 4478ba0..665ac23 100755
--- a/webapp.py
+++ b/webapp.py
@@ -166,6 +166,7 @@ class Application(object):
cursize = -1
files = dict()
minmatch = 2 if pid1 == pid2 else 1
+ cur2 = self.db.cursor()
for cid, filename, size, hashvalue in fetchiter(cur):
if cursize != size:
for entry in files.values():
@@ -181,13 +182,12 @@ class Application(object):
entry = dict(filenames=set((filename,)), size=size, matches={})
files[hashvalue] = entry
- cur2 = self.db.cursor()
cur2.execute("SELECT fa.name, ha.hash, fb.name, filename FROM hash AS ha JOIN hash AS hb ON ha.hash = hb.hash JOIN content ON hb.cid = content.id JOIN function AS fa ON ha.fid = fa.id JOIN function AS fb ON hb.fid = fb.id WHERE ha.cid = ? AND pid = ?;",
(cid, pid2))
for func1, hashvalue, func2, filename in fetchiter(cur2):
entry["matches"].setdefault(filename, {})[func1, func2] = \
hashvalue
- cur2.close()
+ cur2.close()
cur.close()
for entry in files.values():