#31508: ASGI Lifespan Support
-------------------------------+------------------------------------
     Reporter:  Braunson       |                    Owner:  nobody
         Type:  New feature    |                   Status:  new
    Component:  HTTP handling  |                  Version:  3.0
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------

Comment (by Braunson):

 Replying to [comment:2 Carlton Gibson]:
 > Hi. I'm inclined to Accept this as a New Feature.
 >
 > Lifespan is optional (IIUC) but I can imagine folks wanting to use it.
 (Not sure what for exactly but... :)
 > I can't immediately see where the right place for the hooks would be. I
 guess I'd start with an ASGI middleware, at least as PoC.
 >
 > Accepting provisionally on that basis. Interested to see what Andrew
 thinks...?
 >
 >
 > (Seems a bit keen for uvicorn to **warn** over this, with that whole
 ''being optional'' thing... 🤔 — I guess you could pass `--lifespan=off`
 maybe. )
 >
 >

 That is true, you can manually disable it in uvicorn. There is use cases
 for this. One such is Async libraries that only offer asynchronous means
 of initialization. For instance Elasticsearch's async calls can be
 initialized with `await client.login(...)` for example. If you try to use
 the client without this awaited login it will fail.

 So a lifespan feature where you could run some async code for constructing
 objects would be super useful for me.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31508#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.bcff4270690172130bad111500f78f90%40djangoproject.com.

Reply via email to