From 7833053223fd01feeea09714c75291970ca88924 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Thu, 6 Aug 2020 23:43:10 +0530 Subject: [PATCH] [2.9] basic: use PollSelector implementation (#70801) Some platform such as ESXi does not implement EpollSelector, which is selected by DefaultSelector. Use PollSelector which is based upon 'Poll' implementation. 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 5ce83c3ec10..fb5df295799 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -2682,7 +2682,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':