Cache execnet gateway rinfo during WorkerController setup

Cache execnet gateway info during WorkerController setup for backward
compatibility, in order to avoid a later main_thread_only deadlock
error triggered when pytest-cov calls rinfo after the main thread is
already busy. See pytest-dev/execnet#274 for corresponding test case.

Fixes: 20e3ac774e ("Use execnet main_thread_only execmodel (#1027)")
This commit is contained in:
Zac Medico
2024-04-27 11:08:12 -07:00
committed by Ran Benita
parent c93a106b3a
commit 12b3cce0ce
2 changed files with 6 additions and 0 deletions

1
changelog/1071.bugfix Normal file
View File

@@ -0,0 +1 @@
Add backward compatibility for deadlock issue with the ``execnet`` new ``main_thread_only`` "execmodel" triggered when pytest-cov accesses rinfo.

View File

@@ -312,6 +312,11 @@ class WorkerController:
def setup(self) -> None:
self.log("setting up worker session")
# Cache rinfo for backward compatibility, since pytest-cov
# accesses rinfo while the main thread is busy executing our
# remote_exec call, which triggers a deadlock error for the
# main_thread_only execmodel if the rinfo has not been cached.
self.gateway._rinfo()
spec = self.gateway.spec
args = [str(x) for x in self.config.invocation_params.args or ()]
option_dict = {}