Skip to content

ansible_mitogen: Interpreter discovery improvements #1225

@moreati

Description

@moreati

A grab bag of shortcomings, ideas, and a place to disucss them

Finding python to find python

Ansible's native interpreter discovery makes one call to sh, with a list of candidate interepreters from INTERPRETER_PYTHON_FALLBACK. Mitogen turns this into several attempts to call a list of (Mitogen) candidate interpreters. So an O(1) operation becomes O(N).

  • Can the list be shortened and/or the order optimised?
  • Can the O(N) be eliminated?
    • Make an exception to Mitogen's design, call sh with Ansible's snippet instead
    • Devise a shell construction that calls one of the Python interpreters
  • Should the Mitogen list be derived from/enhanced with Ansible's INTERPRETER_PYTHON_FALLBACK list?

# TODO: HACK: if finding python interpreter then we need to keep
# calling exec_command until we run into the right python we'll use
# chicken-and-egg issue, mitogen needs a python to run low_level_execute_command
# which is required by Ansible's discover_interpreter function
if self._finding_python_interpreter:
possible_pythons = [
'/usr/bin/python',
'python3',
'python3.7',
'python3.6',
'python3.5',
'python2.7',
'python2.6',
'/usr/libexec/platform-python',
'/usr/bin/python3',
'python'

/usr/bin/python fallback

Depending on the setting INTERPRETER_PYTHON Ansible may fallback to /usr/bin/python or (I think) throw an error. I'm not convinced Mitogen always respects that setting.

s = run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_python)
# if unable to determine python_path, fallback to '/usr/bin/python'
if not s:
s = '/usr/bin/python'

related

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesignRequiredIssues that cannot progress due to incomplete designfeatureDesign and functional additions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions