Sync from several threads or processes#
One Replica serves every thread of a process, and a SQLite store serves every process on the machine.
Sync scopes at once#
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor() as pool:
for done in [pool.submit(adapter.sync) for adapter in adapters]:
done.result()
Each adapter syncs its own scope, so they run side by side. The store runs one write at a time, with reads beside it. Sync a scope from one thread at a time: a second sync of the same scope in the same process raises SessionError. Your application’s reads don’t wait for a sync, as StateStore describes.