remove RamSession patch

since patch has been incorporated into CherryPy
8030d8a5bf
master
eric 2021-04-23 09:33:12 -04:00
parent 0c95a0d7aa
commit 06a982bdbf
2 changed files with 0 additions and 45 deletions

View File

@ -68,8 +68,6 @@ tools.I18nTool.mo_dir: CherryPyApp.install_dir + '/i18n'
tools.I18nTool.domain: 'messages'
tools.sessions.on: True
tools.sessions.storage_class = sessions.RamSession
#tools.sessions.storage_type = "postgres"
tools.sessions.table_name = "cherrypy.sessions"
tools.sessions.timeout: 30
tools.sessions.path: '/'

View File

@ -1,43 +0,0 @@
# will submit a PR to CherryPy project - if it gets merged we can remove it. ESH 8/15/2019
import cherrypy
from cherrypy.lib.sessions import RamSession as cpRamSession
class RamSession(cpRamSession):
def clean_up(self):
"""Clean up expired sessions."""
now = self.now()
try:
cache_items_copy = self.cache.copy().items()
except RuntimeError as re:
"""Under heavy load, list(self.cache.items()) will occasionally raise this error
for large session caches with message "dictionary changed size during iteration"
Better to pause the cleanup than to let the cleanup thread die.
"""
cherrypy.log(f'Runtime Error happened while copying the cache entries: {re}')
cherrypy.log('Ref: https://github.com/cherrypy/cherrypy/pull/1804')
return
for _id, (data, expiration_time) in cache_items_copy:
if expiration_time <= now:
try:
del self.cache[_id]
except KeyError:
pass
try:
if self.locks[_id].acquire(blocking=False):
lock = self.locks.pop(_id)
lock.release()
except KeyError:
pass
# added to remove obsolete lock objects
for _id in list(self.locks):
locked = (
_id not in self.cache
and self.locks[_id].acquire(blocking=False)
)
if locked:
lock = self.locks.pop(_id)
lock.release()