Does the Python shelve module have any protection built in to make sure two processes aren't writing to a file at the same time?
The shelve module uses an underlying database package (such as dbm, gdbm or bsddb) .
The restrictions pragraph says (my emphasis):
The shelve module does not support concurrent read/write access to shelved objects. (Multiple simultaneous read accesses are safe.) When a program has a shelf open for writing, no other program should have it open for reading or writing. Unix file locking can be used to solve this, but this differs across Unix versions and requires knowledge about the database implementation used.
Conclusion: it depends on OS and the underlying DB. To keep things portable, do not build on concurrency.