<div dir="ltr">Hello,<div><br></div><div>I am trying to determine the best way to introduce a resource clean up logic into a python module that is called using ASGI protocol.</div><div><br></div><div><span style="background-color:rgb(255,255,255)"><font color="#000000" face="arial, sans-serif">I am successfully catching the <i>'lifespan.startup' </i>event  from within my <span style="font-style:italic;white-space:pre">async</span><span style="font-style:italic;white-space:pre"> </span><span style="font-style:italic;white-space:pre">def</span><span style="font-style:italic;white-space:pre"> </span><span style="font-style:italic;white-space:pre">application</span><span style="font-style:italic;white-space:pre">(</span><span style="font-style:italic;white-space:pre">scope</span><span style="font-style:italic;white-space:pre">, </span><span style="font-style:italic;white-space:pre">receive</span><span style="font-style:italic;white-space:pre">, </span><span style="font-style:italic;white-space:pre">send</span><span style="white-space:pre"><i>) </i>implementation.</span></font></span></div><div><span style="background-color:rgb(255,255,255)"><font color="#000000" face="arial, sans-serif"><span style="white-space:pre"><br></span></font></span></div><div><span style="background-color:rgb(255,255,255)"><font color="#000000" face="arial, sans-serif"><span style="white-space:pre">Unfortunately, I do not see </span></font></span>the <i>'lifespan.shutdown' </i>event  when the process is unloaded.</div><div><br></div><div>My config file includes:</div><div>      "processes": {<br>        "max": 3,<br>        "spare": 1,<br>        "idle_timeout": 10<br>      },<br></div><div><br></div><div>I was under the assumption that the above config will force the idle processes to shut down resulting in<font color="#000000" face="arial, sans-serif"><span style="white-space:pre"> </span></font>the <i>'lifespan.shutdown' </i>event .</div><div><br></div><div>Would appreciate any assistance.</div><div>gen</div></div>