mistio/mist.io — pull request #62 by dimrozakis (2014-01-23 23:10:57+00:00)
Title: Add file locking mechanism to make thread safe.

Implement a FileLock mechanism that uses soft links to create a lock.
Create new OODictYamlLock class that uses FileLock and make User
class a subclass of OODictYamlLock.

Every call to lock_n_load locks db.yaml by creating a db.yaml.lock
soft link (atomic operation). If link (lock) already exists, call will
block up to a defined timeout after which it will break the lock.

Also, when saving, data is dumped to db.yaml.tmp file and then moved in
position (atomic operation) to avoid a thread reading halfwritten data.