Skip to content

waitclose in _rinfo() call #118

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

Merged
merged 2 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
------------------

* Dropped support for Python 3.4.
* `#118 <https://github.com/pytest-dev/execnet/pull/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 <https://github.com/pytest-dev/pytest-xdist/issues/620>`__
for an example).


1.7.1 (2019-08-28)
Expand Down
5 changes: 4 additions & 1 deletion execnet/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the waitclose doesn't elicit any response to guarantee that the main thread has been released, I added a one second timeout for it to release as shown in #243 (comment).

return self._cache_rinfo

def hasreceiver(self):
Expand Down