I have a Python application that does the following:
- Is called by another process/processes once every 2-3 minutes in order to store an object using
with shelve.open(shelvefilename, flag='c'). - Is called by another process/processes many times per minute in order to read that shelve file using
with shelve.open(shelvefilename, flag='r')
The problem is that at some time I get a _gdbm.error: [Errno 11] Resource temporarily unavailable Error:
File "/path/to/myprog.py", line 755, in mymethod
with shelve.open(shelvefilename, flag='r') as shlvfile:
File "/usr/local/lib/python3.6/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/local/lib/python3.6/shelve.py", line 227, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/usr/local/lib/python3.6/dbm/__init__.py", line 94, in open
return mod.open(file, flag, mode)
_gdbm.error: [Errno 11] Resource temporarily unavailable
My guess is that this happen because at some moment I have opened the shelve file both for read and write operation which is problematic by definition.
Is there any way that I can make the update to the shelve file without disturbing the read operations?