diff --git a/changelogs/fragments/70238_selector.yml b/changelogs/fragments/70238_selector.yml new file mode 100644 index 00000000000..3a0193d0387 --- /dev/null +++ b/changelogs/fragments/70238_selector.yml @@ -0,0 +1,2 @@ +bugfixes: +- basic - use PollSelector implementation when DefaultSelector fails (https://github.com/ansible/ansible/issues/70238). diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index db90dafd13b..dcc838a0248 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -2603,7 +2603,13 @@ class AnsibleModule(object): stdout = b'' stderr = b'' - selector = selectors.DefaultSelector() + try: + selector = selectors.DefaultSelector() + except OSError: + # Failed to detect default selector for the given platform + # Select PollSelector which is supported by major platforms + selector = selectors.PollSelector() + selector.register(cmd.stdout, selectors.EVENT_READ) selector.register(cmd.stderr, selectors.EVENT_READ) if os.name == 'posix':