mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
(Hopefully) fix a bug where several sig ref data providers try to write to the data store simultaneously on startup.
This commit is contained in:
@@ -36,8 +36,10 @@ class SIGRefDataProvider:
|
||||
def _add_data(self, new_data):
|
||||
"""Add all the provided reference data objects to the data store."""
|
||||
|
||||
# with transact() batches all writes together to save making thousands of individual sqlite writes
|
||||
with DATA_STORE.sigrefs.transact():
|
||||
# with transact() batches all writes together to save making thousands of individual sqlite writes. However,
|
||||
# that means that each provider holds the lock while it writes, and the default behaviour for other attempted
|
||||
# transact()s is to fail if they can't get the lock (?!). This behaviour is fixed by retry=True.
|
||||
with DATA_STORE.sigrefs.transact(retry=True):
|
||||
for d in new_data:
|
||||
DATA_STORE.sigrefs.set(f"{self.sig_name}:{d.id}", d)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user