Skip to content

Commit

Permalink
Avoid unnecessary rinfo calls after creating gateways
Browse files Browse the repository at this point in the history
Hopefully this fixes pytest-dev#907, as seems this is the only
change in pytest-dev#901 which is somehow related.
  • Loading branch information
nicoddemus committed May 18, 2023
1 parent 52a6143 commit 29885b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 2 additions & 0 deletions changelog/907.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Avoid unnecessary remote calls during node startup, which might trigger a bug in execnet that causes
tests to execute in threads other than the main thread.
31 changes: 15 additions & 16 deletions src/xdist/dsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,26 +444,25 @@ def pytest_xdist_setupnodes(self, specs) -> None:

@pytest.hookimpl
def pytest_xdist_newgateway(self, gateway) -> None:
rinfo = gateway._rinfo()
is_local = rinfo.executable == sys.executable
if self.config.option.verbose > 0 and not is_local:
version = "%s.%s.%s" % rinfo.version_info[:3]
self.rewrite(
"[%s] %s Python %s cwd: %s"
% (gateway.id, rinfo.platform, version, rinfo.cwd),
newline=True,
)
if self.config.option.verbose > 0:
rinfo = gateway._rinfo()
different_interpreter = rinfo.executable != sys.executable
if different_interpreter:
version = "%s.%s.%s" % rinfo.version_info[:3]
self.rewrite(
f"[{gateway.id}] {rinfo.platform} Python {version} cwd: {rinfo.cwd}",
newline=True,
)
self.setstatus(gateway.spec, WorkerStatus.Initialized, tests_collected=0)

@pytest.hookimpl
def pytest_testnodeready(self, node) -> None:
d = node.workerinfo
is_local = d.get("executable") == sys.executable
if self.config.option.verbose > 0 and not is_local:
infoline = "[{}] Python {}".format(
d["id"], d["version"].replace("\n", " -- ")
)
self.rewrite(infoline, newline=True)
if self.config.option.verbose > 0:
d = node.workerinfo
different_interpreter = d.get("executable") != sys.executable
if different_interpreter:
version = d["version"].replace("\n", " -- ")
self.rewrite(f"[{d['id']}] Python {version}", newline=True)
self.setstatus(
node.gateway.spec, WorkerStatus.ReadyForCollection, tests_collected=0
)
Expand Down

0 comments on commit 29885b0

Please sign in to comment.