diff --git a/src/execnet/gateway.py b/src/execnet/gateway.py index 547be291..f79f3dde 100644 --- a/src/execnet/gateway.py +++ b/src/execnet/gateway.py @@ -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: