MCPcopy
hub / github.com/django/django / clear_expired

Method clear_expired

django/contrib/sessions/backends/file.py:209–222  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

207
208 @classmethod
209 def clear_expired(cls):
210 storage_path = cls._get_storage_path()
211 file_prefix = settings.SESSION_COOKIE_NAME
212
213 for session_file in os.listdir(storage_path):
214 if not session_file.startswith(file_prefix):
215 continue
216 session_key = session_file.removeprefix(file_prefix)
217 session = cls(session_key)
218 # When an expired session is loaded, its file is removed, and a
219 # new file is immediately created. Prevent this by disabling
220 # the create() method.
221 session.create = lambda: None
222 session.load()
223
224 @classmethod
225 async def aclear_expired(cls):

Callers 1

aclear_expiredMethod · 0.45

Calls 3

_get_storage_pathMethod · 0.80
listdirMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected