Skip to content

Commit 3a7e9b4

Browse files
kevin-batesZsailer
authored andcommitted
Fix concurrency test to wait for completion
1 parent 2ef0826 commit 3a7e9b4

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

kernel_gateway/tests/test_notebook_http.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Distributed under the terms of the Modified BSD License.
33
"""Tests for notebook-http mode."""
44

5+
import asyncio
56
import os
67
import json
78
import pytest
@@ -227,25 +228,17 @@ async def test_should_cycle_through_kernels(self, jp_fetch, jp_argv):
227228
else:
228229
assert response.body == b"hola {}\n", "Unexpected body in response to GET after performing PUT."
229230

231+
@pytest.mark.timeout(10)
230232
async def test_concurrent_request_should_not_be_blocked(self, jp_fetch, jp_argv):
231233
"""Concurrent requests should not be blocked"""
232234
response_long_running = jp_fetch("sleep", "6", method="GET")
233-
if callable(getattr(response_long_running, "done", "")):
234-
# Tornado 5
235-
assert response_long_running.done() is False, "Long HTTP Request is not running"
236-
else:
237-
# Tornado 4
238-
assert response_long_running.running() is True, "Long HTTP Request is not running"
235+
assert response_long_running.done() is False, "Long HTTP Request is not running"
239236

240237
response_short_running = await jp_fetch("sleep", "3", method="GET")
241-
if callable(getattr(response_long_running, "done", "")):
242-
# Tornado 5
243-
assert response_long_running.done() is False, "Long HTTP Request is not running"
244-
else:
245-
# Tornado 4
246-
assert response_long_running.running() is True, "Long HTTP Request is not running"
247-
248238
assert response_short_running.code == 200, "Short HTTP Request did not return proper status code of 200"
239+
assert response_long_running.done() is False, "Long HTTP Request is not running"
240+
while not response_long_running.done():
241+
await asyncio.sleep(0.3) # let the long request complete
249242

250243
async def test_locking_semaphore_of_kernel_resources(self, jp_fetch, jp_argv):
251244
"""Kernel pool should prevent more than one request from running on a kernel at a time.

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ coverage
22
pytest
33
pytest-cov
44
pytest_jupyter
5+
pytest-timeout
56
ipykernel

0 commit comments

Comments
 (0)