Avoid unnecessary rinfo calls after creating gateways (#909)
Hopefully this fixes #907, as seems this is the only change in #901 which is somehow related. --------- Co-authored-by: Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>
This commit is contained in:
5
changelog/907.bugfix.rst
Normal file
5
changelog/907.bugfix.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
Avoid remote calls during startup as ``execnet`` by default does not ensure remote affinity with the
|
||||
main thread and might accidentally schedule the pytest worker into a non-main thread, which breaks numerous frameworks,
|
||||
for example ``asyncio``, ``anyio``, ``PyQt/PySide``, etc.
|
||||
|
||||
A more safe correction will require thread affinity in ``execnet`` (`pytest-dev/execnet#96 <https://github.com/pytest-dev/execnet/issues/96>`__).
|
||||
@@ -444,26 +444,25 @@ class TerminalDistReporter:
|
||||
|
||||
@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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user