File tree Expand file tree Collapse file tree
packages/pynumaflow/pynumaflow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6161# If NUM_THREADS_DEFAULT env is not set default to 4
6262NUM_THREADS_DEFAULT = int (os .getenv ("MAX_THREADS" , "4" ))
6363
64+ # Grace period in seconds for the GRPC server to shutdown
65+ NUMAFLOW_GRPC_SHUTDOWN_GRACE_PERIOD_SECONDS = int (
66+ os .getenv ("NUMAFLOW_GRPC_SHUTDOWN_GRACE_PERIOD_SECONDS" , "60" )
67+ )
68+
6469_LOGGER = setup_logging (__name__ )
6570if os .getenv ("PYTHONDEBUG" ):
6671 _LOGGER .setLevel (logging .DEBUG )
Original file line number Diff line number Diff line change 2626 ON_SUCCESS_SINK_SOCK_PATH ,
2727 ON_SUCCESS_SINK_SERVER_INFO_FILE_PATH ,
2828 MAX_NUM_THREADS ,
29+ NUMAFLOW_GRPC_SHUTDOWN_GRACE_PERIOD_SECONDS ,
2930)
3031
3132from pynumaflow .shared .server import NumaflowServer
@@ -168,9 +169,9 @@ async def _watch_for_shutdown():
168169 """Wait for the shutdown event and stop the server with a grace period."""
169170 await shutdown_event .wait ()
170171 _LOGGER .info ("Shutdown signal received, stopping server gracefully..." )
171- # Stop accepting new requests and wait for a maximum of 5 seconds
172- # for in-flight requests to complete
173- await server .stop (5 )
172+ # Stop accepting new requests and wait for a maximum of
173+ # NUMAFLOW_GRPC_SHUTDOWN_GRACE_PERIOD_SECONDS seconds for in-flight requests to complete
174+ await server .stop (NUMAFLOW_GRPC_SHUTDOWN_GRACE_PERIOD_SECONDS )
174175
175176 shutdown_task = asyncio .create_task (_watch_for_shutdown ())
176177 await server .wait_for_termination ()
You can’t perform that action at this time.
0 commit comments