Skip to content

Relax timings of subshell tests #1374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
- Fix expected text depending on IPython version. [#1354](https://github.com/ipython/ipykernel/pull/1354) ([@Carreau](https://github.com/Carreau))
- Another try at tracking down ResourceWarning with tracemalloc. [#1353](https://github.com/ipython/ipykernel/pull/1353) ([@Carreau](https://github.com/Carreau))
- Remove deprecated modules since 4.3 (2016). [#1352](https://github.com/ipython/ipykernel/pull/1352) ([@Carreau](https://github.com/Carreau))
- Try to reenable tests from downstream ipywidgets [#1350](https://github.com/ipython/ipykernel/pull/1350) ([@Carreau](https://github.com/Carreau))
- Try to re-enable tests from downstream ipywidgets [#1350](https://github.com/ipython/ipykernel/pull/1350) ([@Carreau](https://github.com/Carreau))
- Disable 3 failing downstream tests, but keep testing the rest. [#1349](https://github.com/ipython/ipykernel/pull/1349) ([@Carreau](https://github.com/Carreau))
- Licence :: * trove classifers are deprecated [#1348](https://github.com/ipython/ipykernel/pull/1348) ([@Carreau](https://github.com/Carreau))
- Licence :: * trove classifiers are deprecated [#1348](https://github.com/ipython/ipykernel/pull/1348) ([@Carreau](https://github.com/Carreau))
- Pin sphinx to resolve docs build failures [#1347](https://github.com/ipython/ipykernel/pull/1347) ([@krassowski](https://github.com/krassowski))
- Make our own mock kernel methods async [#1346](https://github.com/ipython/ipykernel/pull/1346) ([@Carreau](https://github.com/Carreau))
- Try to debug non-closed iopub socket [#1345](https://github.com/ipython/ipykernel/pull/1345) ([@Carreau](https://github.com/Carreau))
- Email is @python.org since 2018 [#1343](https://github.com/ipython/ipykernel/pull/1343) ([@Carreau](https://github.com/Carreau))
- Remove unused ignores lints. [#1342](https://github.com/ipython/ipykernel/pull/1342) ([@Carreau](https://github.com/Carreau))
- Enable ruff G002 and fix 6 occurences [#1341](https://github.com/ipython/ipykernel/pull/1341) ([@Carreau](https://github.com/Carreau))
- Enable ruff G002 and fix 6 occurrences [#1341](https://github.com/ipython/ipykernel/pull/1341) ([@Carreau](https://github.com/Carreau))
- Check ignores warnings are still relevant. [#1340](https://github.com/ipython/ipykernel/pull/1340) ([@Carreau](https://github.com/Carreau))
- Move mypy disablinging error codes on a per-file basis [#1338](https://github.com/ipython/ipykernel/pull/1338) ([@Carreau](https://github.com/Carreau))
- try to fix spyder kernel install [#1337](https://github.com/ipython/ipykernel/pull/1337) ([@Carreau](https://github.com/Carreau))
Expand All @@ -46,7 +46,7 @@
- Bump mypy [#1333](https://github.com/ipython/ipykernel/pull/1333) ([@Carreau](https://github.com/Carreau))
- Remove dead code. [#1332](https://github.com/ipython/ipykernel/pull/1332) ([@Carreau](https://github.com/Carreau))
- Ignore or fix most of the remaining ruff 0.9.6 errors [#1331](https://github.com/ipython/ipykernel/pull/1331) ([@Carreau](https://github.com/Carreau))
- minor code reformating valid ruff 0.9.6 [#1330](https://github.com/ipython/ipykernel/pull/1330) ([@Carreau](https://github.com/Carreau))
- minor code reformatting valid ruff 0.9.6 [#1330](https://github.com/ipython/ipykernel/pull/1330) ([@Carreau](https://github.com/Carreau))
- Some formatting changes to prepare bumping ruff pre-commit. [#1329](https://github.com/ipython/ipykernel/pull/1329) ([@Carreau](https://github.com/Carreau))
- Manually update Codespell and fix new errors. [#1328](https://github.com/ipython/ipykernel/pull/1328) ([@Carreau](https://github.com/Carreau))
- Manually update mdformat pre-commit and run it. [#1327](https://github.com/ipython/ipykernel/pull/1327) ([@Carreau](https://github.com/Carreau))
Expand Down
16 changes: 11 additions & 5 deletions tests/test_subshells.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def test_thread_ids():
)
@pytest.mark.parametrize("are_subshells", [(False, True), (True, False), (True, True)])
@pytest.mark.parametrize("overlap", [True, False])
def test_run_concurrently_sequence(are_subshells, overlap):
def test_run_concurrently_sequence(are_subshells, overlap, request):
if request.config.getvalue("--cov"):
pytest.skip("Skip time-sensitive subshell tests if measuring coverage")

with new_kernel() as kc:
subshell_ids = [
create_subshell_helper(kc)["subshell_id"] if is_subshell else None
Expand All @@ -143,7 +146,7 @@ def test_run_concurrently_sequence(are_subshells, overlap):
kc, "import threading as t, time; b=t.Barrier(2); print('ok')", None
)

sleep = 0.2
sleep = 0.5
if overlap:
codes = [
f"b.wait(); start0=True; end0=False; time.sleep({sleep}); end0=True",
Expand Down Expand Up @@ -173,7 +176,10 @@ def test_run_concurrently_sequence(are_subshells, overlap):


@pytest.mark.parametrize("include_main_shell", [True, False])
def test_run_concurrently_timing(include_main_shell):
def test_run_concurrently_timing(include_main_shell, request):
if request.config.getvalue("--cov"):
pytest.skip("Skip time-sensitive subshell tests if measuring coverage")

with new_kernel() as kc:
subshell_ids = [
None if include_main_shell else create_subshell_helper(kc)["subshell_id"],
Expand All @@ -186,7 +192,7 @@ def test_run_concurrently_timing(include_main_shell):
kc, "import threading as t, time; b=t.Barrier(2); print('ok')", None
)

times = (0.2, 0.2)
times = (0.5, 0.5)
# Prepare messages, times are sleep times in seconds.
# Identical times for both subshells is a harder test as preparing and sending
# the execute_reply messages may overlap.
Expand Down Expand Up @@ -230,7 +236,7 @@ def test_execution_count():
)

# Prepare messages
times = (0.2, 0.1, 0.4, 0.15) # Sleep seconds
times = (0.4, 0.2, 0.8, 0.3) # Sleep seconds
msgs = []
for i, (id, sleep) in enumerate(zip((None, subshell_id, None, subshell_id), times)):
code = f"b.wait(); time.sleep({sleep})" if i < 2 else f"time.sleep({sleep})"
Expand Down
Loading