These are chat archives for cherrypy/cherrypy
CherryPy is a pythonic, object-oriented HTTP framework. | post your issues to: github.com/cherrypy/cherrypy/issues | FAQ: https://stackoverflow.com/questions/tagged/cheroot+or+cherrypy
I'm running into something unexpected with
cherrypy.session.locking = 'explicit'. I have a number of streaming responses that take a long time, and so I wanted to manage the session locks by hand so they wouldn't block for each other. However, with session.locking as 'explicit', the automatic 'session._save' that occurs in the 'before_finalize' hook complains:
AssertionError: The session was saved without being locked. Check your tools' priority levels.
This appears to be because of the
hooks.attach('before_finalize', _sessions.save) in _cptools.py:316.
So it appears that the session has to be locked before this part of the request runs. If this is intentional, it's not clear from the documentation why. Is this intentional? Am I missing something about the way I should be handling my session data (locking before use, unlocking after)? If locking is explicit, should the 'before_finalize' save hook do it's own lock, or is that a bad idea?
before_finalizethat locks the session for the
savecall, and another in
on_end_resourcethat unlocks it. It seems to work. But I worry I'm missing something that will come back to bite me if I do this, there ought to be a better way.