|
2 | 2 | # Distributed under the terms of the Modified BSD License. |
3 | 3 | """Tests for notebook-http mode.""" |
4 | 4 |
|
| 5 | +import asyncio |
5 | 6 | import os |
6 | 7 | import json |
7 | 8 | import pytest |
@@ -227,25 +228,17 @@ async def test_should_cycle_through_kernels(self, jp_fetch, jp_argv): |
227 | 228 | else: |
228 | 229 | assert response.body == b"hola {}\n", "Unexpected body in response to GET after performing PUT." |
229 | 230 |
|
| 231 | + @pytest.mark.timeout(10) |
230 | 232 | async def test_concurrent_request_should_not_be_blocked(self, jp_fetch, jp_argv): |
231 | 233 | """Concurrent requests should not be blocked""" |
232 | 234 | 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" |
239 | 236 |
|
240 | 237 | 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 | | - |
248 | 238 | 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 |
249 | 242 |
|
250 | 243 | async def test_locking_semaphore_of_kernel_resources(self, jp_fetch, jp_argv): |
251 | 244 | """Kernel pool should prevent more than one request from running on a kernel at a time. |
|
0 commit comments