From dcae2ac32315f451007594c9c37a6c276097c4b1 Mon Sep 17 00:00:00 2001 From: sqozz Date: Sun, 1 Apr 2018 19:44:49 +0200 Subject: [PATCH] Close used db connections --- indexer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indexer.py b/indexer.py index fffe497..9f1e7d7 100644 --- a/indexer.py +++ b/indexer.py @@ -88,6 +88,7 @@ class ScrapeState(): c = connection.cursor() c.execute("SELECT fileid FROM torrents") all_hashes = c.fetchall() + connection.close() for info_hash in all_hashes: info_hash = info_hash[0] url_param = binascii.a2b_hex(info_hash.encode()) @@ -132,6 +133,7 @@ def download(filename): c = connection.cursor() c.execute("SELECT name FROM torrents WHERE fileid = :fileid", { 'fileid' : filename}) name = c.fetchone()[0] + connection.close() return send_file("torrentFiles/" + filename, as_attachment=True, attachment_filename=name + ".torrent", conditional=True) @@ -170,6 +172,7 @@ def search(): r = row[0:2] + (size(float(row[2])) , ) + row[3:] results.append(r) + connection.close() return render_template("result.html", results=results, categories=categories.categories, stats=scrapeState.stats)