diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-09-11 08:35:41 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-09-11 08:35:41 +0200 |
commit | 786c4f93ea318a3c22479f80531594435fb036c3 (patch) | |
tree | f6522faeb72908c5e8cc61c1ddc2d6225dfb918e /webapp.py | |
parent | ca65a78a9ace0aeb2565df0da171727c04c33970 (diff) | |
download | debian-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.
Diffstat (limited to 'webapp.py')
-rwxr-xr-x | webapp.py | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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(): |