From 12b3cce0ce4f4cffcc35c0e8369759b71b32c0cc Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 27 Apr 2024 11:08:12 -0700 Subject: [PATCH] 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: 20e3ac774e8f ("Use execnet main_thread_only execmodel (#1027)") --- changelog/1071.bugfix | 1 + src/xdist/workermanage.py | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 changelog/1071.bugfix diff --git a/changelog/1071.bugfix b/changelog/1071.bugfix new file mode 100644 index 00000000..089a4ef1 --- /dev/null +++ b/changelog/1071.bugfix @@ -0,0 +1 @@ +Add backward compatibility for deadlock issue with the ``execnet`` new ``main_thread_only`` "execmodel" triggered when pytest-cov accesses rinfo. diff --git a/src/xdist/workermanage.py b/src/xdist/workermanage.py index 5570e1de..44d1be4c 100644 --- a/src/xdist/workermanage.py +++ b/src/xdist/workermanage.py @@ -312,6 +312,11 @@ def shutting_down(self) -> bool: 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 = {}