commit 851159f02ed7cad6db5ead4d99cdd4d6b1f0ce3b Author: Damian Johnson atagar@torproject.org Date: Sat Sep 2 13:53:35 2017 -0700
Allow cache to be accessed from multiple threads
Huh, didn't expect it to reject multithreading by default. Using the cache fails with...
ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140437876885248 and this is thread id 140437570447104
SQLite has a parameter to drop this check. Should be safe since we do the locking ourselves. There's discussion about the option on...
https://bugs.python.org/issue27113 --- nyx/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nyx/__init__.py b/nyx/__init__.py index 26b490d..b3cbafb 100644 --- a/nyx/__init__.py +++ b/nyx/__init__.py @@ -362,7 +362,7 @@ class Cache(object):
if cache_path: try: - self._conn = sqlite3.connect(cache_path) + self._conn = sqlite3.connect(cache_path, check_same_thread = False) schema = self._conn.execute('SELECT version FROM schema').fetchone()[0] except: schema = None @@ -377,13 +377,13 @@ class Cache(object):
self._conn.close() os.remove(cache_path) - self._conn = sqlite3.connect(cache_path) + self._conn = sqlite3.connect(cache_path, check_same_thread = False)
for cmd in SCHEMA: self._conn.execute(cmd) else: stem.util.log.info('Unable to cache to disk. Using an in-memory cache instead.') - self._conn = sqlite3.connect(':memory:') + self._conn = sqlite3.connect(':memory:', check_same_thread = False)
for cmd in SCHEMA: self._conn.execute(cmd)
tor-commits@lists.torproject.org