From 84ffea8cf926a0da257af4ca0c368328e9b55d46 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 25 Jan 2021 11:46:03 +0000 Subject: [PATCH 1/2] waitclose in _rinfo() call should improve https://github.com/pytest-dev/pytest-xdist/issues/620 --- execnet/gateway.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/execnet/gateway.py b/execnet/gateway.py index 5e367c02..87fde943 100644 --- a/execnet/gateway.py +++ b/execnet/gateway.py @@ -75,7 +75,10 @@ def _rinfo(self, update=False): """ return some sys/env information from remote. """ if update or not hasattr(self, "_cache_rinfo"): ch = self.remote_exec(rinfo_source) - self._cache_rinfo = RInfo(ch.receive()) + try: + self._cache_rinfo = RInfo(ch.receive()) + finally: + ch.waitclose() return self._cache_rinfo def hasreceiver(self): From f0cfea40bb3695ccac607a35b49be138f9246dba Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 27 Jan 2021 07:54:33 -0300 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f43cee45..4b443401 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,13 @@ ------------------ * Dropped support for Python 3.4. +* `#118 `__: Fixed internal leak that should make + ``execnet`` execute remote code in the main thread more often; previously it would sometimes + spawn a thread to execute a ``remote_exec`` call, even when the caller + didn't issue multiple ``remote_exec`` calls at the same time. Some frameworks require code + to execute in the main thread, so the previous behavior would break them on occasion (see + `pytest-dev/pytest-xdist#620 `__ + for an example). 1.7.1 (2019-08-28)