If multiple executions are reading from the same shelve, I assume that they must open it in read-only mode so that there are no "locked file" errors. I'm using shelve as a cache, which is intended to be populated on the first run. When the code runs, it checks the integrity of the cache, and regenerates it when needed. Because of my context, it is safe to assume that if the cache is being updated, the code is never running concurrently. How do I open and upgrade/downgrade the shelve to and from create and read-only mode to avoid locked file errors while also allowing concurrent executions? Continue reading...