Allow multithreaded SQLite on Python 3

Former-commit-id: bf0071fd8b
This commit is contained in:
Robyn Speer 2014-10-02 18:10:09 -04:00
parent 5153faf43e
commit 03fac20b1b

View File

@ -5,8 +5,10 @@ import sys
if sys.version_info.major == 2: if sys.version_info.major == 2:
from functools32 import lru_cache from functools32 import lru_cache
PY2 = True
else: else:
from functools import lru_cache from functools import lru_cache
PY2 = False
SQLITE_ERROR_TEXT = """ SQLITE_ERROR_TEXT = """
Couldn't open the wordlist database. Couldn't open the wordlist database.
@ -20,7 +22,10 @@ This can be configured by setting the WORDFREQ_DATA environment variable.
""" % {'path': DB_FILENAME} """ % {'path': DB_FILENAME}
try: 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: except sqlite3.OperationalError:
raise IOError(SQLITE_ERROR_TEXT) raise IOError(SQLITE_ERROR_TEXT)