aboutsummaryrefslogtreecommitdiff
path: root/src/Database.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-02-25 10:36:17 +0000
committerGravatar jesopo2019-02-25 10:36:17 +0000
commitd627ed49e22ba9c57e50cd6de748a9f26fc03720 (patch)
tree3ca7f6397b2108d620314a849402c566e5dfc79c /src/Database.py
parentMinor code stylisation in imgur.py (diff)
signature
Pull "is main thread" logic out to utils, force Database to be accessed on main
thread
Diffstat (limited to 'src/Database.py')
-rw-r--r--src/Database.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Database.py b/src/Database.py
index 1ba9bac3..c498b4a8 100644
--- a/src/Database.py
+++ b/src/Database.py
@@ -1,5 +1,5 @@
import json, os, sqlite3, threading, time, typing
-from src import Logging
+from src import Logging, utils
sqlite3.register_converter("BOOLEAN", lambda v: bool(int(v)))
@@ -309,6 +309,9 @@ class Database(object):
def _execute_fetch(self, query: str,
fetch_func: typing.Callable[[sqlite3.Cursor], typing.Any],
params: typing.List=[]):
+ if not utils.is_main_thread():
+ raise RuntimeError("Can't access Database outside of main thread")
+
printable_query = " ".join(query.split())
start = time.monotonic()