Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pytest-dev/pytest-xdist
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.2.0
Choose a base ref
...
head repository: pytest-dev/pytest-xdist
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.2.1
Choose a head ref
  • 9 commits
  • 5 files changed
  • 4 contributors

Commits on Feb 7, 2023

  1. Merge pull request #875 from pytest-dev/release-3.2.0

    Release 3.2.0
    amezin authored Feb 7, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2329d34 View commit details

Commits on Feb 13, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5e795d8 View commit details
  2. Merge pull request #878 from akx/patch-1

    docs: Remove unused statement in one-log-per-worker example
    nicoddemus authored Feb 13, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5d692a7 View commit details

Commits on Feb 14, 2023

  1. [pre-commit.ci] pre-commit autoupdate

    updates:
    - [github.com/pre-commit/mirrors-mypy: v0.991 → v1.0.0](pre-commit/mirrors-mypy@v0.991...v1.0.0)
    pre-commit-ci[bot] authored Feb 14, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    efe674b View commit details
  2. Merge pull request #879 from pytest-dev/pre-commit-ci-update-config

    [pre-commit.ci] pre-commit autoupdate
    nicoddemus authored Feb 14, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ba526fa View commit details

Commits on Feb 27, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#881)

    updates:
    - [github.com/pre-commit/mirrors-mypy: v1.0.0 → v1.0.1](pre-commit/mirrors-mypy@v1.0.0...v1.0.1)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored Feb 27, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    58fd7cc View commit details

Commits on Mar 9, 2023

  1. Copy the full SHA
    6abcdfc View commit details

Commits on Mar 10, 2023

  1. Merge pull request #885 from amezin/steal-hang-fix

    Fix hang caused by `steal` command with empty test queue
    amezin authored Mar 10, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b6c195a View commit details

Commits on Mar 12, 2023

  1. Release 3.2.1

    amezin committed Mar 12, 2023
    Copy the full SHA
    b591be4 View commit details
Showing with 59 additions and 4 deletions.
  1. +1 −1 .pre-commit-config.yaml
  2. +9 −0 CHANGELOG.rst
  3. +0 −1 docs/how-to.rst
  4. +15 −2 src/xdist/remote.py
  5. +34 −0 testing/test_remote.py
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ repos:
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.0.1
hooks:
- id: mypy
files: ^(src/|testing/)
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
pytest-xdist 3.2.1 (2023-03-12)
===============================

Bug Fixes
---------

- `#884 <https://github.com/pytest-dev/pytest-xdist/issues/884>`_: Fixed hang in ``worksteal`` scheduler.


pytest-xdist 3.2.0 (2023-02-07)
===============================

1 change: 0 additions & 1 deletion docs/how-to.rst
Original file line number Diff line number Diff line change
@@ -221,7 +221,6 @@ Example:
def pytest_configure(config):
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
if worker_id is not None:
log_file = config.getini("worker_log_file")
logging.basicConfig(
format=config.getini("log_file_format"),
filename=f"tests_{worker_id}.log",
17 changes: 15 additions & 2 deletions src/xdist/remote.py
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ def worker_title(title):

class WorkerInteractor:
SHUTDOWN_MARK = object()
QUEUE_REPLACED_MARK = object()

def __init__(self, config, channel):
self.config = config
@@ -72,6 +73,15 @@ def __init__(self, config, channel):
def _make_queue(self):
return self.channel.gateway.execmodel.queue.Queue()

def _get_next_item_index(self):
"""Gets the next item from test queue. Handles the case when the queue
is replaced concurrently in another thread.
"""
result = self.torun.get()
while result is self.QUEUE_REPLACED_MARK:
result = self.torun.get()
return result

def sendevent(self, name, **kwargs):
self.log("sending", name, kwargs)
self.channel.send((name, kwargs))
@@ -136,19 +146,22 @@ def old_queue_get_nowait_noraise():
self.torun.put(i)

self.sendevent("unscheduled", indices=stolen)
old_queue.put(self.QUEUE_REPLACED_MARK)

@pytest.hookimpl
def pytest_runtestloop(self, session):
self.log("entering main loop")
self.channel.setcallback(self.handle_command, endmarker=self.SHUTDOWN_MARK)
self.nextitem_index = self.torun.get()
self.nextitem_index = self._get_next_item_index()
while self.nextitem_index is not self.SHUTDOWN_MARK:
self.run_one_test()
return True

def run_one_test(self):
self.item_index = self.nextitem_index
self.nextitem_index = self._get_next_item_index()

items = self.session.items
self.item_index, self.nextitem_index = self.nextitem_index, self.torun.get()
item = items[self.item_index]
if self.nextitem_index is self.SHUTDOWN_MARK:
nextitem = None
34 changes: 34 additions & 0 deletions testing/test_remote.py
Original file line number Diff line number Diff line change
@@ -271,6 +271,40 @@ def test_func4(): pass
ev = worker.popevent("workerfinished")
assert "workeroutput" in ev.kwargs

def test_steal_empty_queue(self, worker: WorkerSetup, unserialize_report) -> None:
worker.pytester.makepyfile(
"""
def test_func(): pass
def test_func2(): pass
"""
)
worker.setup()
ev = worker.popevent("collectionfinish")
ids = ev.kwargs["ids"]
assert len(ids) == 2
worker.sendcommand("runtests_all")

for when in ["setup", "call", "teardown"]:
ev = worker.popevent("testreport")
rep = unserialize_report(ev.kwargs["data"])
assert rep.nodeid.endswith("::test_func")
assert rep.when == when

worker.sendcommand("steal", indices=[0, 1])
ev = worker.popevent("unscheduled")
assert ev.kwargs["indices"] == []

worker.sendcommand("shutdown")

for when in ["setup", "call", "teardown"]:
ev = worker.popevent("testreport")
rep = unserialize_report(ev.kwargs["data"])
assert rep.nodeid.endswith("::test_func2")
assert rep.when == when

ev = worker.popevent("workerfinished")
assert "workeroutput" in ev.kwargs


def test_remote_env_vars(pytester: pytest.Pytester) -> None:
pytester.makepyfile(