Skip to content

Commit b5fed9c

Browse files
authored
Merge pull request #388 from kevin-bates/cull-test-idle-timeout
Increase culling test idle timeout
2 parents 1b7f6fe + 083f7be commit b5fed9c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/services/kernels/test_cull.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ def jp_argv(request):
1313
return ["--ServerApp.kernel_manager_class=jupyter_server.services.kernels.kernelmanager." + request.param]
1414

1515

16-
CULL_TIMEOUT = 10 if platform.python_implementation() == 'PyPy' else 2
16+
CULL_TIMEOUT = 10 if platform.python_implementation() == 'PyPy' else 5
17+
CULL_INTERVAL = 1
18+
1719

1820
@pytest.fixture
1921
def jp_server_config():
2022
return Config({
2123
'ServerApp': {
2224
'MappingKernelManager': {
2325
'cull_idle_timeout': CULL_TIMEOUT,
24-
'cull_interval': 1,
26+
'cull_interval': CULL_INTERVAL,
2527
'cull_connected': False
2628
}
2729
}
@@ -56,18 +58,19 @@ async def test_culling(jp_fetch, jp_ws_fetch):
5658

5759

5860
async def get_cull_status(kid, jp_fetch):
61+
frequency = 0.5
5962
culled = False
60-
for i in range(20): # Need max of 2x culling PERIOD ensure culling timeout exceeded
63+
for _ in range(int((CULL_TIMEOUT + CULL_INTERVAL)/frequency)): # Timeout + Interval will ensure cull
6164
try:
6265
r = await jp_fetch(
6366
'api', 'kernels', kid,
6467
method='GET'
6568
)
66-
kernel = json.loads(r.body.decode())
69+
json.loads(r.body.decode())
6770
except HTTPClientError as e:
6871
assert e.code == 404
6972
culled = True
7073
break
7174
else:
72-
await asyncio.sleep(CULL_TIMEOUT / 10.)
73-
return culled
75+
await asyncio.sleep(frequency)
76+
return culled

0 commit comments

Comments
 (0)