Ticket #717: session_len.patch
-
cherrypy/__init__.py
old new 267 267 def __contains__(self, key): 268 268 child = getattr(serving, self.__attrname__) 269 269 return key in child 270 271 def __len__(self): 272 child = getattr(serving, self.__attrname__) 273 return len(child) 270 274 271 275 272 276 # Create request and response object (the same objects will be used -
cherrypy/lib/sessions.py
old new 233 233 def release_lock(self): 234 234 self.locks[self.id].release() 235 235 self.locked = False 236 237 def __len__(self): 238 "Returns number of active sessions" 239 return len(self.cache) 236 240 237 241 238 242 class FileSession(Session): … … 328 332 os.unlink(path) 329 333 finally: 330 334 self.release_lock(path) 335 336 def __len__(self): 337 "Returns number of active sessions" 338 sessions = os.listdir(self.storage_path) 339 sessions = [fname for fname in sessions if (fname.startswith(self.SESSION_PREFIX) and not fname.endswith(self.LOCK_SUFFIX))] 340 return len(sessions) 341 342 331 343 332 344 333 345 class PostgresqlSession(Session):

