Bug 2339 - fournir une documentation utilisateur de physix

tentative de correction d'un bug qui cause l'erreur suivante d'apparaitre de temps en temps, à l'occasion du chargement de la page clusteruserguide :


SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 139672342353664 and this is thread id 139672333960960
This commit is contained in:
Guillaume Raffy 2018-06-28 12:43:30 +00:00
parent 64813cb35a
commit c750804914
1 changed files with 6 additions and 1 deletions

View File

@ -84,7 +84,12 @@ class SqlFile(ISqlDatabaseBackend):
os.remove(sqlite_db_path)
except:
pass
self._con = sqlite3.connect(sqlite_db_path)
check_same_thread = False
# this is to prevent the following error when run from apache/django : SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 139672342353664 and this is thread id 139672333960960
# accordig to https://stackoverflow.com/questions/48218065/programmingerror-sqlite-objects-created-in-a-thread-can-only-be-used-in-that-sa this is ok, as long as there are no concurrent writes
# If set False, the returned connection may be shared across multiple threads. When using multiple threads with the same connection writing operations should be serialized by the user to avoid data corruption
# I hope it's safe here but I'm not 100% sure though. Anyway, if the database gets corrupt, it not a big deal since this memory resident database gets reconstructed from the sql file...
self._con = sqlite3.connect(sqlite_db_path, check_same_thread=check_same_thread)
f = open(self._sql_file_path, 'r')
sql = f.read() # watch out for built-in `str`
#print(sql)