diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 8ae8682e..dc98451f 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -504,7 +504,9 @@ class Connection(ansible.plugins.connection.ConnectionBase): loader_basedir = None # set by `_get_task_vars()` for interpreter discovery - _action = None + # we need it to be an object with the value of "_finding_python_interpreter" in case we aren't + # running interpreter discovery fully + _action = type('actionTemp', (object,), {'_finding_python_interpreter': False}) # redeclaring interpreter discovery vars here in case running ansible < 2.8.0 _discovered_interpreter_key = None _discovered_interpreter = False @@ -564,7 +566,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): # so we don't walk the stack to find them # TODO: is there a better way to get the ActionModuleMixin object? # ansible python discovery needs it to run discover_interpreter() - if not hasattr(self, '_action'): + if not isinstance(self._action, ansible_mitogen.mixins.ActionModuleMixin): f = sys._getframe() while f: if f.f_code.co_name == 'run': diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index 92456dba..5b043bca 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -87,7 +87,7 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action): # calls low_level_exec_command which then retriggers spec.python_path() # in connect_ssh(), so we'll return the default '/usr/bin/python' to finish building the stack # TODO: possible issues here? Chicken-and-egg issue, in order to `connect_ssh` we need a python path - if action is None or action._finding_python_interpreter or s is None: + if action._finding_python_interpreter or s is None: return '/usr/bin/python' if s in ['auto', 'auto_legacy', 'auto_silent', 'auto_legacy_silent']: