MCPcopy
hub / github.com/django/django / aget_expiry_age

Method aget_expiry_age

django/contrib/sessions/backends/base.py:300–317  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

298 return delta.days * 86400 + delta.seconds
299
300 async def aget_expiry_age(self, **kwargs):
301 try:
302 modification = kwargs["modification"]
303 except KeyError:
304 modification = timezone.now()
305 try:
306 expiry = kwargs["expiry"]
307 except KeyError:
308 expiry = await self.aget("_session_expiry")
309
310 if not expiry: # Checks both None and 0 cases
311 return self.get_session_cookie_age()
312 if not isinstance(expiry, (datetime, str)):
313 return expiry
314 if isinstance(expiry, str):
315 expiry = datetime.fromisoformat(expiry)
316 delta = expiry - modification
317 return delta.days * 86400 + delta.seconds
318
319 def get_expiry_date(self, **kwargs):
320 """Get session the expiry date (as a datetime object).

Callers 10

aloadMethod · 0.80
asaveMethod · 0.80
asaveMethod · 0.80

Calls 3

agetMethod · 0.95
nowMethod · 0.45