Skip to content

Feat(Session): Reuse session from our DB and only regenerate it when expired

Gerard Funosas requested to merge retry-session-if-expired into master

Reuse MM auth sessions saving them into our DB, and only recomputing them when expired.

Add method regenerate_session_if_expired as decorator for that purpose



In [1]: from api.models.MM_session import MMSession

In [2]: from api.asset import Asset

In [3]: MMSession.objects.last()  # Empty

In [4]: asset_service = Asset("12345", "change_tariff")

In [5]: asset_service.session
Out[5]: <pymasmovil.models.session.Session at 0x7f65922eaf10>

In [6]: MMSession.objects.last().token == asset_service.session.session_id   # Not Empty
Out[6]: True

Edited by Gerard Funosas

Merge request reports

Loading