Skip to content
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

Use execnet main_thread_only execmodel #1

Draft
wants to merge 53 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
51ef944
Avoid modifying path placeholders created by editable installs
jeremy-hiatt Feb 28, 2024
79fb6ff
testing: Add test to assert path hooks ignored in sys.path
jeremy-hiatt Feb 28, 2024
54720c1
Merge pull request #1030 from jeremy-hiatt/dont-rewrite-path-hooks
RonnyPfannschmidt Mar 1, 2024
0596f27
Bump the github-actions group with 1 update (#1035)
dependabot[bot] Mar 4, 2024
74887e3
Fix incompatibility error with `--pdb` despite using `-n0` (#938)
atugushev Mar 5, 2024
a9801a4
Bump the github-actions group with 2 updates (#1037)
dependabot[bot] Mar 12, 2024
5b83de4
[pre-commit.ci] pre-commit autoupdate (#1039)
pre-commit-ci[bot] Mar 13, 2024
74edbeb
[pre-commit.ci] pre-commit autoupdate (#1044)
pre-commit-ci[bot] Mar 19, 2024
00dc8ee
Remove pytest InvocationParams backward compat
bluetech Mar 23, 2024
74f5752
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 23, 2024
dde8a66
Merge pull request #1047 from bluetech/rm-invocationparams-compat
nicoddemus Apr 1, 2024
84df445
Terminate the test loop if `shouldfail` or `shouldstop` is set (#1026)
bbrown1867 Apr 1, 2024
940c4fc
Bump the github-actions group with 1 update
dependabot[bot] Apr 1, 2024
8f7bd68
Merge pull request #1050 from pytest-dev/dependabot/github_actions/gi…
nicoddemus Apr 1, 2024
e3b69d4
Sort imports
bluetech Apr 2, 2024
c01de1c
Make docstring style more consistent
bluetech Apr 2, 2024
816c9dc
Use ruff instead of black, flake8, autoflake, pyupgrade
bluetech Apr 2, 2024
b6f5d2b
Merge pull request #1051 from bluetech/ruff
bluetech Apr 3, 2024
d63400e
testing: replace `testdir` -> `pytester`
bluetech Apr 3, 2024
a790dc5
Drop support for Python 3.7
bluetech Apr 3, 2024
d96d87e
Merge pull request #1054 from bluetech/rm-py37
RonnyPfannschmidt Apr 3, 2024
470bc83
Merge pull request #1052 from bluetech/pytester
bluetech Apr 3, 2024
fbf2eca
ci: add a job for min supported pytest version
bluetech Apr 4, 2024
99b767b
Merge pull request #1056 from bluetech/ci-pytestmin
bluetech Apr 5, 2024
31de42f
Bump min pytest to 7.0.0
bluetech Apr 4, 2024
dd067e4
Merge pull request #1058 from bluetech/pytest-min-7
bluetech Apr 5, 2024
e9084f2
Bump min execnet to 2.1.0
bluetech Apr 5, 2024
3e92604
Merge pull request #1059 from bluetech/execnet-min
bluetech Apr 6, 2024
5dcc10c
dsession: remove unnecessary `getplugin("runner")`
bluetech Apr 3, 2024
8e77d14
testing: fix an assert
bluetech Apr 3, 2024
503c5ee
loadscope: remove redundant None check
bluetech Apr 3, 2024
ef5dcde
each: remove incorrect `mark_test_pending` implementation
bluetech Apr 3, 2024
4057da1
remote: use `perf_counter()` to measure duration, not `time()`
bluetech Apr 4, 2024
a3b9a98
looponfail: remove unneeded `setup(out)` parameter
bluetech Apr 4, 2024
5c676aa
dsession,workermanage: drop handling of `pytest_captured_warning`
bluetech Apr 4, 2024
024c73f
testing: fix a private pytest import to its current location
bluetech Apr 4, 2024
ee0b09c
loadscope: use dict instead of OrderedDict
bluetech Apr 5, 2024
059c1bc
remote,workermanage: use enums for markers
bluetech Apr 5, 2024
e7a971b
Use `from __future__ import annotations`
bluetech Apr 3, 2024
d6c81d5
pre-commit: remove py from typing deps, add types-psutil
bluetech Apr 5, 2024
29aa05f
testing: add `worksteal` to `TestLocking` tests
bluetech Apr 5, 2024
cdff86a
pyproject: make plain `mypy` run work
bluetech Apr 5, 2024
4720808
Merge pull request #1060 from bluetech/pre-typing-fixes
bluetech Apr 6, 2024
7c3f70f
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Apr 8, 2024
91812bf
Merge pull request #1062 from pytest-dev/pre-commit-ci-update-config
nicoddemus Apr 10, 2024
bf2dccc
Add a Scheduling Protocol
bluetech Apr 5, 2024
5dfc590
Merge pull request #1061 from bluetech/scheduling-proto
bluetech Apr 15, 2024
b78cf1c
Improve typing
bluetech Apr 18, 2023
ecf7c1c
Merge pull request #1065 from bluetech/typing
bluetech Apr 16, 2024
0686279
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Apr 15, 2024
0a4238f
Merge pull request #1067 from pytest-dev/pre-commit-ci-update-config
nicoddemus Apr 17, 2024
a30949c
Use execnet main_thread_only execmodel
zmedico Feb 25, 2024
c82fee1
Create 1027.improvement.rst
nicoddemus Feb 29, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v2.0
uses: hynek/build-and-inspect-python-package@v2.2

deploy:
needs: package
Expand All @@ -39,7 +39,7 @@ jobs:
path: dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.11
uses: pypa/gh-action-pypi-publish@v1.8.14

- name: Push tag
run: |
Expand All @@ -49,7 +49,7 @@ jobs:
git push origin v${{ github.event.inputs.version }}

- name: GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: dist/*
tag_name: v${{ github.event.inputs.version }}
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v2.0
uses: hynek/build-and-inspect-python-package@v2.2

test:

Expand All @@ -34,7 +34,7 @@ jobs:
fail-fast: false
matrix:
tox_env:
- "py37-pytestlatest"
- "py38-pytestmin"
- "py38-pytestlatest"
- "py39-pytestlatest"
- "py310-pytestlatest"
Expand All @@ -46,8 +46,8 @@ jobs:

os: [ubuntu-latest, windows-latest]
include:
- tox_env: "py37-pytestlatest"
python: "3.7"
- tox_env: "py38-pytestmin"
python: "3.8"
- tox_env: "py38-pytestlatest"
python: "3.8"
- tox_env: "py39-pytestlatest"
Expand Down
38 changes: 12 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
repos:
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.0
hooks:
- id: autoflake
args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"]
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
args: [--safe, --quiet, --target-version, py35]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.7"
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.1.0]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py3-plus]
- repo: local
hooks:
- id: rst
Expand All @@ -39,11 +23,13 @@ repos:
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.9.0
hooks:
- id: mypy
files: ^(src/|testing/)
args: []
additional_dependencies:
- pytest>=6.2.0
- py>=1.10.0
- pytest>=7.0.0
- execnet>=2.1.0
- types-psutil
- setproctitle
2 changes: 2 additions & 0 deletions changelog/1024.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added proper handling of ``shouldstop`` (such as set by ``--max-fail``) and ``shouldfail`` conditions in workers.
Previously, a worker might have continued executing further tests before the controller could terminate the session.
3 changes: 3 additions & 0 deletions changelog/1027.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``pytest-xdist`` workers now always execute the tests in the main thread.

Previously some tests might end up executing in a separate thread other than ``main`` in the workers, due to some internal `èxecnet`` details. This can cause problems specially with async frameworks where the event loop is running in the ``main`` thread (for example `#620 <https://github.com/pytest-dev/pytest-xdist/issues/620>`__).
1 change: 1 addition & 0 deletions changelog/1028.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compatiblity issue between `looponfail` and editable installs.
1 change: 1 addition & 0 deletions changelog/1053.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped support for Python 3.7.
3 changes: 3 additions & 0 deletions changelog/1057.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest>=7.0.0 is now required.

execnet>=2.1.0 is now required.
1 change: 1 addition & 0 deletions changelog/1057.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The internals of pytest-xdist are now fully typed. The typing is not exposed yet.
1 change: 1 addition & 0 deletions changelog/620.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the ``execnet`` new ``main_thread_only`` "execmodel" so that code which expects to only run in the main thread will now work as expected.
1 change: 1 addition & 0 deletions changelog/937.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug where plugin would raise an incompatibility error with ``--pdb`` despite using ``-n0``.
95 changes: 75 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.7"
requires-python = ">=3.8"
dependencies = [
"execnet>=1.1",
"pytest>=6.2.0",
"execnet>=2.1",
"pytest>=7.0.0",
]
dynamic = ["version"]

Expand Down Expand Up @@ -67,26 +66,82 @@ include-package-data = false
[tool.setuptools_scm]
write_to = "src/xdist/_version.py"

[tool.flake8]
# Ignore any errors related to formatting, let black worry/fix them.
ignore = ["E501", "W503", "E203"]
max-line-length = 100
[tool.ruff]
src = ["src"]

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
select = [
"B", # bugbear
"D", # pydocstyle
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"PYI", # flake8-pyi
"UP", # pyupgrade
"RUF", # ruff
"W", # pycodestyle
"T10", # flake8-debugger
"PIE", # flake8-pie
"FA", # flake8-future-annotations
"PGH", # pygrep-hooks
"PLE", # pylint error
"PLW", # pylint warning
"PLR1714", # Consider merging multiple comparisons
]
ignore = [
# bugbear ignore
"B011", # Do not `assert False` (`python -O` removes these calls)
"B028", # No explicit `stacklevel` keyword argument found
# pydocstyle ignore
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D105", # Missing docstring in magic method
"D106", # Missing docstring in public nested class
"D107", # Missing docstring in `__init__`
"D209", # Multi-line docstring closing quotes should be on a separate line
"D205", # 1 blank line required between summary line and description
"D400", # First line should end with a period
"D401", # First line of docstring should be in imperative mood
# ruff ignore
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
# pylint ignore
"PLW0603", # Using the global statement
"PLW0120", # remove the else and dedent its contents
"PLW2901", # for loop variable overwritten by assignment target
"PLR5501", # Use `elif` instead of `else` then `if`
]

[tool.ruff.lint.pycodestyle]
# In order to be able to format for 88 char in ruff format
max-line-length = 120

[tool.ruff.lint.pydocstyle]
convention = "pep257"

[tool.ruff.lint.isort]
force-single-line = true
combine-as-imports = true
force-sort-within-sections = true
order-by-type = false
lines-after-imports = 2

[tool.ruff.lint.per-file-ignores]
"src/xdist/_version.py" = ["I001"]

[tool.mypy]
mypy_path = ["src"]
# TODO: Enable this & fix errors.
# check_untyped_defs = true
disallow_any_generics = true
ignore_missing_imports = true
no_implicit_optional = true
show_error_codes = true
strict_equality = true
warn_redundant_casts = true
warn_return_any = true
files = ["src", "testing"]
strict = true
warn_unreachable = true
warn_unused_configs = true
# TODO: Enable this & fix errors.
# no_implicit_reexport = true
[[tool.mypy.overrides]]
module = ["xdist._version"]
ignore_missing_imports = true


[tool.towncrier]
Expand Down
11 changes: 5 additions & 6 deletions src/xdist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from xdist.plugin import (
is_xdist_worker,
is_xdist_master,
get_xdist_worker_id,
is_xdist_controller,
)
from xdist._version import version as __version__
from xdist.plugin import get_xdist_worker_id
from xdist.plugin import is_xdist_controller
from xdist.plugin import is_xdist_master
from xdist.plugin import is_xdist_worker


__all__ = [
"__version__",
Expand Down
5 changes: 3 additions & 2 deletions src/xdist/_path.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
from itertools import chain
import os
from pathlib import Path
from typing import Callable, Iterator
from typing import Callable
from typing import Iterator


def visit_path(
Expand Down
Loading