session.DiskStore concurrency issue
When hammering web.py with a huge amount of requests whereby each request updates the session, exceptions will be thrown. (Usually during the decode of the pickle string from the disk but other exceptions are possible)
We believe that if one thread is writing the session info, that a second thread that reads/writes to the same session simultaneously will cause an uncaught exception.
A possible solution is to update session.DiskStore.setitem to become:
def __setitem__(self, key, value):
path = self._get_path(key)
pickled = self.encode(value)
try:
tname = path+"."+threading.current_thread().getName()
f = open(tname, 'w')
try:
f.write(pickled)
finally:
f.close()
os.rename(tname, path) # atomary operation
except IOError:
pass