Added a file locking for the shelve db.

This should deter db corruption if multiple users are trying to run
write operations at the same time. Parallel read operations are still
allowed.