davidlatwe / montydb

Monty, Mongo tinified. MongoDB implemented in Python !

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential race condition fix?

dgutson opened this issue · comments

I observed this change in @c4p-n1ck's fork:

master...c4p-n1ck:montydb:master#diff-822d717926e4514a846fad4aecc14e0cfcd9f30b60eca800667359921e6a5022R96

-       self.__conn = sqlite3.connect(db_file)
+      self.__conn = sqlite3.connect(db_file, check_same_thread=False)

Should that be brought here?

Hmmm, just had a quick look.

I think what we could do is adding that check_same_thread as an config option at here:

def config(cls, journal_mode="WAL", **kwargs):

Then the config should be used to initialize a SQLite storage engine instance here:

class SQLiteKVEngine(object):
def __init__(self, db_pragmas):
self.__db_pragmas = db_pragmas
self.__conn = None

At the moment, SQLite config is being used to keep database pargmas, but it could do more than that. And check_same_thread is a good fit.

so it is not a race condition fix? Sorry about my ignorance.

Don't be sorry! I am not familiar with this either.

But we certainly can add check_same_thread as a connection option though. Since it will affect the behavior of how a sqlite connection reacts to different thread, so we would want it to be optionable. ☺️

Feature added in 2.5.2, closing this now. 😃

u rock!