File tree Expand file tree Collapse file tree
packages/pynumaflow/pynumaflow/sinker Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ async def _watch_for_shutdown():
168168 """Wait for the shutdown event and stop the server with a grace period."""
169169 await shutdown_event .wait ()
170170 _LOGGER .info ("Shutdown signal received, stopping server gracefully..." )
171+ # Stop accepting new requests and wait for a maximum of 5 seconds for existing requests to complete
171172 await server .stop (5 )
172173
173174 shutdown_task = asyncio .create_task (_watch_for_shutdown ())
@@ -181,5 +182,8 @@ async def _watch_for_shutdown():
181182 await shutdown_task
182183
183184 _LOGGER .info ("Stopping event loop..." )
185+ # We use aiorun to manage the event loop. The aiorun.run() runs forever until loop.stop() is called.
186+ # If we don't stop the event loop explicitly here, the python process will not exit.
187+ # It reamins stuck for 5 minutes until liveness and readiness probe fails enough times and k8s sends a SIGTERM
184188 asyncio .get_event_loop ().stop ()
185189 _LOGGER .info ("Event loop stopped" )
You can’t perform that action at this time.
0 commit comments