@@ -186,6 +186,7 @@ def init_gateway(monkeypatch):
186186 monkeypatch .setenv ("JUPYTER_GATEWAY_HTTP_USER" , mock_http_user )
187187 monkeypatch .setenv ("JUPYTER_GATEWAY_REQUEST_TIMEOUT" , "44.4" )
188188 monkeypatch .setenv ("JUPYTER_GATEWAY_CONNECT_TIMEOUT" , "44.4" )
189+ monkeypatch .setenv ("JUPYTER_GATEWAY_LAUNCH_TIMEOUT_PAD" , "1.1" )
189190 yield
190191 GatewayClient .clear_instance ()
191192
@@ -198,11 +199,10 @@ async def test_gateway_env_options(init_gateway, jp_serverapp):
198199 jp_serverapp .gateway_config .connect_timeout == jp_serverapp .gateway_config .request_timeout
199200 )
200201 assert jp_serverapp .gateway_config .connect_timeout == 44.4
202+ assert jp_serverapp .gateway_config .launch_timeout_pad == 1.1
201203
202204 GatewayClient .instance ().init_static_args ()
203- assert GatewayClient .instance ().KERNEL_LAUNCH_TIMEOUT == int (
204- jp_serverapp .gateway_config .request_timeout
205- )
205+ assert GatewayClient .instance ().KERNEL_LAUNCH_TIMEOUT == 43
206206
207207
208208async def test_gateway_cli_options (jp_configurable_serverapp ):
@@ -211,6 +211,7 @@ async def test_gateway_cli_options(jp_configurable_serverapp):
211211 "--GatewayClient.http_user=" + mock_http_user ,
212212 "--GatewayClient.connect_timeout=44.4" ,
213213 "--GatewayClient.request_timeout=96.0" ,
214+ "--GatewayClient.launch_timeout_pad=5.1" ,
214215 ]
215216
216217 GatewayClient .clear_instance ()
@@ -221,10 +222,40 @@ async def test_gateway_cli_options(jp_configurable_serverapp):
221222 assert app .gateway_config .http_user == mock_http_user
222223 assert app .gateway_config .connect_timeout == 44.4
223224 assert app .gateway_config .request_timeout == 96.0
225+ assert app .gateway_config .launch_timeout_pad == 5.1
224226 GatewayClient .instance ().init_static_args ()
225227 assert (
226- GatewayClient .instance ().KERNEL_LAUNCH_TIMEOUT == 96
227- ) # Ensure KLT gets set from request-timeout
228+ GatewayClient .instance ().KERNEL_LAUNCH_TIMEOUT == 90
229+ ) # Ensure KLT gets set from request-timeout - launch_timeout_pad
230+ GatewayClient .clear_instance ()
231+
232+
233+ @pytest .mark .parametrize (
234+ "request_timeout,kernel_launch_timeout,expected_request_timeout,expected_kernel_launch_timeout" ,
235+ [(50 , 10 , 50 , 45 ), (10 , 50 , 55 , 50 )],
236+ )
237+ async def test_gateway_request_timeout_pad_option (
238+ jp_configurable_serverapp ,
239+ monkeypatch ,
240+ request_timeout ,
241+ kernel_launch_timeout ,
242+ expected_request_timeout ,
243+ expected_kernel_launch_timeout ,
244+ ):
245+ argv = [
246+ f"--GatewayClient.request_timeout={ request_timeout } " ,
247+ "--GatewayClient.launch_timeout_pad=5" ,
248+ ]
249+
250+ GatewayClient .clear_instance ()
251+ app = jp_configurable_serverapp (argv = argv )
252+
253+ monkeypatch .setattr (GatewayClient , "KERNEL_LAUNCH_TIMEOUT" , kernel_launch_timeout )
254+ GatewayClient .instance ().init_static_args ()
255+
256+ assert app .gateway_config .request_timeout == expected_request_timeout
257+ assert GatewayClient .instance ().KERNEL_LAUNCH_TIMEOUT == expected_kernel_launch_timeout
258+
228259 GatewayClient .clear_instance ()
229260
230261
0 commit comments