<div dir="ltr">Thank you very Max.<div><br></div><div>Your example and suggestion to look into the unit.log helped me to resolve the issue.</div><div><br></div><div>Gen</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 28, 2020 at 12:59 PM Max Romanov <<a href="mailto:max.romanov@nginx.com">max.romanov@nginx.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">Hello,<div><br></div><div>Could you please check the unit.log file for message like "Got invalid state transition on lifespan protocol" ?</div><div>This message means there is an unexpected reaction in response to 'lifespan.startup' event. For instance, you don’t send the 'lifespan.startup.complete' message or return from your application function before reading the 'lifespan.shutdown'.</div><div><br></div><div>Working example is attached.</div><div><br></div><div>—</div><div>Max</div><div><br></div><div></div></div><div style="overflow-wrap: break-word;"><div><br><div><br><blockquote type="cite"><div>On 28 Dec 2020, at 20:04, Bot-Publishing Inc. <<a href="mailto:info@botpublishing.com" target="_blank">info@botpublishing.com</a>> wrote:</div><br><div><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 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-wrap">async</span><span style="font-style:italic;white-space:pre-wrap"> </span><span style="font-style:italic;white-space:pre-wrap">def</span><span style="font-style:italic;white-space:pre-wrap"> </span><span style="font-style:italic;white-space:pre-wrap">application</span><span style="font-style:italic;white-space:pre-wrap">(</span><span style="font-style:italic;white-space:pre-wrap">scope</span><span style="font-style:italic;white-space:pre-wrap">, </span><span style="font-style:italic;white-space:pre-wrap">receive</span><span style="font-style:italic;white-space:pre-wrap">, </span><span style="font-style:italic;white-space:pre-wrap">send</span><span style="white-space:pre-wrap"><i>) </i>implementation.</span></font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="arial, sans-serif"><span style="white-space:pre-wrap"><br></span></font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="arial, sans-serif"><span style="white-space:pre-wrap">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 face="arial, sans-serif"><span style="white-space:pre-wrap"> </span></font>the <i>'lifespan.shutdown' </i>event .</div><div><br></div><div>Would appreciate any assistance.</div><div>gen</div></div>
_______________________________________________<br>unit mailing list<br><a href="mailto:unit@nginx.org" target="_blank">unit@nginx.org</a><br><a href="https://mailman.nginx.org/mailman/listinfo/unit" target="_blank">https://mailman.nginx.org/mailman/listinfo/unit</a></div></blockquote></div><br></div></div>_______________________________________________<br>
unit mailing list<br>
<a href="mailto:unit@nginx.org" target="_blank">unit@nginx.org</a><br>
<a href="https://mailman.nginx.org/mailman/listinfo/unit" rel="noreferrer" target="_blank">https://mailman.nginx.org/mailman/listinfo/unit</a></blockquote></div>