From f3849eeb484bf2a43f6e262b962a88972d387919 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Thu, 19 Jan 2017 20:04:45 +0100 Subject: [PATCH] Unused imports, problematic variable names --- src/inventory.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/inventory.py b/src/inventory.py index dfe35b8b..d175035d 100644 --- a/src/inventory.py +++ b/src/inventory.py @@ -1,5 +1,4 @@ import collections -import pprint from threading import current_thread, enumerate as threadingEnumerate, RLock import time @@ -46,7 +45,7 @@ class Inventory(collections.MutableMapping): def __iter__(self): with self.lock: hashes = self._inventory.keys()[:] - hashes += (hash for hash, in sqlQuery('SELECT hash FROM inventory')) + hashes += (x for x, in sqlQuery('SELECT hash FROM inventory')) return hashes.__iter__() def __len__(self): @@ -66,23 +65,23 @@ class Inventory(collections.MutableMapping): def unexpired_hashes_by_stream(self, stream): with self.lock: t = int(time.time()) - hashes = [hash for hash, value in self._inventory.items() if value.stream == stream and value.expires > t] + hashes = [x for x, value in self._inventory.items() if value.stream == stream and value.expires > t] hashes += (payload for payload, in sqlQuery('SELECT hash FROM inventory WHERE streamnumber=? AND expirestime>?', stream, t)) return hashes def flush(self): with self.lock: # If you use both the inventoryLock and the sqlLock, always use the inventoryLock OUTSIDE of the sqlLock. with SqlBulkExecute() as sql: - for hash, value in self._inventory.items(): - sql.execute('INSERT INTO inventory VALUES (?, ?, ?, ?, ?, ?)', hash, *value) + for objectHash, value in self._inventory.items(): + sql.execute('INSERT INTO inventory VALUES (?, ?, ?, ?, ?, ?)', objectHash, *value) self._inventory.clear() def clean(self): with self.lock: sqlExecute('DELETE FROM inventory WHERE expirestime