I have a simple Python class that subclasses from Thread. In the run method, I connect to sqlite db, make a simple select query, and close the connection. Pretty standard stuff:
def run(self):
conn = sqlite3.connect(SHAPE_CACHE_DB)
curs = conn.cursor()
curs.execute('SELECT * from foo')
for row in curs.fetchall():
# do stuff
curs.close()
conn.close()
When only one thread is run at a time, the run method executes very fast - lets just < 1 second. But if multiple instances of the class are instantiated and run - lets say 6 or more, the run method can take many seconds???
I am guessing there is some contention between read access amongst the threads. But I thought sqlite allowed read access to concurrent threads???
Aucun commentaire:
Enregistrer un commentaire