pythonthread-safetyshelve

Is shelve in Python thread safe?


Is shelve in Python used for data persistence thread safe? If not, what's a good alternative?


Solution

  • From the standard library documentation about the Shelve module, under the heading Restrictions:

    The shelve module does not support concurrent read/write access to shelved objects. (Multiple simultaneous read accesses are safe.)

    I would assume that it's probably implementation dependent and in which case, in order to be sure, I would conclude that it certainly is not thread safe.