-
Hi, can multiple threads overwrite each other's writes? Does tinydb handle something like this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@jgarte I've taken the liberty to move this to the discussions section as I think that's the best place to, well, discuss questions like these 🙂 Basically TinyDB doesn't handle this – at all. TinyDB expects you to either only write data from a single thread or use some kind of locking to make sure multiple threads don't create data corruption issues. The reasoning behind this is that TinyDB's design goals are 1) simplicity and 2) extensibility. The latter in particular means that there is no one-size-fits-all locking mechanism that would work with every imaginable storage backend that one could implement. And even if writing to the storage is atomic, TinyDB's Of course, one can implement a locking middleware that could work with any storage backend and would use something like use Python's Does that help? |
Beta Was this translation helpful? Give feedback.
@jgarte I've taken the liberty to move this to the discussions section as I think that's the best place to, well, discuss questions like these 🙂
Basically TinyDB doesn't handle this – at all. TinyDB expects you to either only write data from a single thread or use some kind of locking to make sure multiple threads don't create data corruption issues. The reasoning behind this is that TinyDB's design goals are 1) simplicity and 2) extensibility. The latter in particular means that there is no one-size-fits-all locking mechanism that would work with every imaginable storage backend that one could implement. And even if writing to the storage is atomic, TinyDB's
insert
andupdate
methods are…