Error in ansible Python API

I have encountered an error while working with ansible Python API.

Error : “the connection plugin ‘<class ‘ansible.utils.sentinel.Sentinel’>’ was not found”

I googled this error and found this answer : https://github.com/ansible/ansible/issues/59390

I want to know is there any way I can resolve this error.

I am using and Python version - 3.5 and Ansible version - 2.8.3

Code to run the playbook:

import os
import json
from collections import namedtuple
from ansible import context
from ansible.module_utils.common.collections import ImmutableDict
from ansible.utils.vars import load_extra_vars
from ansible.parsing.dataloader import DataLoader
from ansible.vars.manager import VariableManager
from ansible.inventory.manager import InventoryManager
from ansible.playbook.play import Play
from ansible.executor.playbook_executor import PlaybookExecutor

def execute_ansible_playbook(CLOUD_TO_USE=None, PLAYBOOK=None):
playbook_path = PLAYBOOK
inventory_path = “hosts”

Options = namedtuple(‘Options’, [‘extra_vars’])
loader = DataLoader()
passwords = dict(vault_pass=‘secret’)

inventory = InventoryManager(loader=loader, sources=‘inventory/’ + CLOUD_TO_USE)
variable_manager = VariableManager(loader=loader, inventory=inventory)
executor = PlaybookExecutor(
playbooks=[playbook_path],
inventory=inventory,
variable_manager=variable_manager,
loader=loader,
passwords=passwords
)
results = executor.run()
#print (results)