@@ -186,6 +186,7 @@ def init_gateway(monkeypatch):
186
186
monkeypatch .setenv ("JUPYTER_GATEWAY_HTTP_USER" , mock_http_user )
187
187
monkeypatch .setenv ("JUPYTER_GATEWAY_REQUEST_TIMEOUT" , "44.4" )
188
188
monkeypatch .setenv ("JUPYTER_GATEWAY_CONNECT_TIMEOUT" , "44.4" )
189
+ monkeypatch .setenv ("JUPYTER_GATEWAY_LAUNCH_TIMEOUT_PAD" , "1.1" )
189
190
yield
190
191
GatewayClient .clear_instance ()
191
192
@@ -198,11 +199,10 @@ async def test_gateway_env_options(init_gateway, jp_serverapp):
198
199
jp_serverapp .gateway_config .connect_timeout == jp_serverapp .gateway_config .request_timeout
199
200
)
200
201
assert jp_serverapp .gateway_config .connect_timeout == 44.4
202
+ assert jp_serverapp .gateway_config .launch_timeout_pad == 1.1
201
203
202
204
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
206
206
207
207
208
208
async def test_gateway_cli_options (jp_configurable_serverapp ):
@@ -211,6 +211,7 @@ async def test_gateway_cli_options(jp_configurable_serverapp):
211
211
"--GatewayClient.http_user=" + mock_http_user ,
212
212
"--GatewayClient.connect_timeout=44.4" ,
213
213
"--GatewayClient.request_timeout=96.0" ,
214
+ "--GatewayClient.launch_timeout_pad=5.1" ,
214
215
]
215
216
216
217
GatewayClient .clear_instance ()
@@ -221,10 +222,40 @@ async def test_gateway_cli_options(jp_configurable_serverapp):
221
222
assert app .gateway_config .http_user == mock_http_user
222
223
assert app .gateway_config .connect_timeout == 44.4
223
224
assert app .gateway_config .request_timeout == 96.0
225
+ assert app .gateway_config .launch_timeout_pad == 5.1
224
226
GatewayClient .instance ().init_static_args ()
225
227
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
+
228
259
GatewayClient .clear_instance ()
229
260
230
261
0 commit comments