Skip to content

Commit

Permalink
gateway: Cache rinfo for main_thread_only
Browse files Browse the repository at this point in the history
This should fix a bug triggered by pytest-cov when it tries to
call _rinfo after the gateway is already busy with a remote_exec
call:

pytest-dev/pytest-xdist#1070 (comment)
  • Loading branch information
zmedico committed Apr 19, 2024
1 parent 4999a10 commit 14e2b61
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/execnet/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def __init__(self, io: IO, spec: XSpec) -> None:
super().__init__(io=io, id=spec.id, _startcount=1)
self.spec = spec
self._initreceive()
if self.execmodel.backend == "main_thread_only":
# This will cause a deadlock if there is already a running
# remote_exec, so cache the result before there are any
# other remote_exec calls.
self._rinfo()

@property
def remoteaddress(self) -> str:
Expand Down

0 comments on commit 14e2b61

Please sign in to comment.