From 18dd73c14740b37fcc21cc3e3e4a91fbb217fc32 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Thu, 23 Jul 2020 06:56:47 +0530 Subject: [PATCH] [2.10] basic: use PollSelector implementation (#70800) Some platform such as ESXi does not implement EpollSelector, which is selected by DefaultSelector. Use PollSelector. This works perfectly with a platform like VMware ESXi. Fixes: #70238 Signed-off-by: Abhijeet Kasurde (cherry picked from commit 8cccede0d435c799385828ce55521c910dc69b13) --- changelogs/fragments/70238_selector.yml | 2 ++ lib/ansible/module_utils/basic.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/70238_selector.yml 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':