Skip to content

Commit e1e91ba

Browse files
committed
documentation comments
Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
1 parent 39d64ac commit e1e91ba

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/pynumaflow/pynumaflow/sinker/async_server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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")

0 commit comments

Comments
 (0)