EOFError when loading empty session files
It appears for whatever reason I occasionally end up empty web.py session files:
File "/usr/local/lib/python2.7/site-packages/web/session.py", line 199, in decode, referer: https://onestop.lbl.gov/onestop/
return pickle.loads(pickled), referer: https://xyz.lbl.gov/webapp/
EOFError, referer: https://xyz.lbl.gov/webapp/
It seems like web.py could catch the EOFError and pretend there was no session file. If that isn't right, should I catch the call to web.session.Session()?
if web.config.get('_session') is None:
session = web.session.Session(APP,
web.session.DiskStore(os.path.join(ROOT, 'sessions')), {'user': 'anonymous'})
web.config._session = session
else:
session = web.config._session
What's the preferred way to deal with this?