From bf0071fd8be08cdd3e8362eed200cb9ce65a3187 Mon Sep 17 00:00:00 2001 From: Rob Speer Date: Thu, 2 Oct 2014 18:10:09 -0400 Subject: [PATCH] Allow multithreaded SQLite on Python 3 --- wordfreq/query.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wordfreq/query.py b/wordfreq/query.py index d708f40..c868c59 100644 --- a/wordfreq/query.py +++ b/wordfreq/query.py @@ -5,8 +5,10 @@ import sys if sys.version_info.major == 2: from functools32 import lru_cache + PY2 = True else: from functools import lru_cache + PY2 = False SQLITE_ERROR_TEXT = """ Couldn't open the wordlist database. @@ -20,7 +22,10 @@ This can be configured by setting the WORDFREQ_DATA environment variable. """ % {'path': DB_FILENAME} try: - CONN = sqlite3.connect(DB_FILENAME) + if PY2: + CONN = sqlite3.connect(DB_FILENAME) + else: + CONN = sqlite3.connect(DB_FILENAME, check_same_thread=False) except sqlite3.OperationalError: raise IOError(SQLITE_ERROR_TEXT)