Skip to content

Lifespan

Lynara handles the lifespan protocol of ASGI with it's LifespanInterface. LifespanInterface while being an interface it's quite different from the HTTPInterfaces both in it's role and behavior.

The Lynara.run utility allows to specify which lifespan mode should be used

from lynara import LifespanMode, Lynara

lynara = Lynara(app=django_asgi_app, lifespan_mode=LifespanMode.AUTO)

There are 3 modes:

  • OFF - the lifespan interface will not be used at all
  • ON - the lifespan interface will be used, if the application fails to handle it, it will error out
  • AUTO - similar to ON, but will not fail if the application does not handle lifespans