# Buggy code
def __init__(
    self,
    inventory,
    variable_manager,
    loader,
    options,
    passwords,
    stdout_callback=None,
    run_additional_callbacks=True,
    run_tree=False,
):
    self._inventory = inventory
    self._variable_manager = variable_manager
    self._loader = loader
    self._options = options
    self._stats = AggregateStats()
    self.passwords = passwords
    self._stdout_callback = stdout_callback
    self._run_additional_callbacks = run_additional_callbacks
    self._run_tree = run_tree

    self._callbacks_loaded = False
    self._callback_plugins = []
    self._start_at_done = False

    # make sure any module paths (if specified) are added to the module_loader
    if options.module_path:
        for path in options.module_path:
            if path:
                module_loader.add_directory(path)

    # a special flag to help us exit cleanly
    self._terminated = False

    # this dictionary is used to keep track of notified handlers
    self._notified_handlers = dict()
    self._listening_handlers = dict()

    # dictionaries to keep track of failed/unreachable hosts
    self._failed_hosts = dict()
    self._unreachable_hosts = dict()

    self._final_q = multiprocessing.Queue()

    # A temporary file (opened pre-fork) used by connection
    # plugins for inter-process locking.
    self._connection_lockfile = tempfile.TemporaryFile()


# Traceback (OSError)
# ansible-playbook -vvv -i'localhost,' playbook_build.yml
ansible-playbook 2.6.1
config file = None
configured module search path = [u'/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516]
No config file found; using defaults
Parsed localhost, inventory source with host_list plugin
ERROR! Unexpected Exception, this is probably a bug: [Errno 38] Function not implemented
the full traceback was:

Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook", line 118, in <module>
exit_code = cli.run()
File "/usr/local/lib/python2.7/dist-packages/ansible/cli/playbook.py", line 120, in run
passwords=passwords)
File "/usr/local/lib/python2.7/dist-packages/ansible/executor/playbook_executor.py", line 60, in __init__
self._tqm = TaskQueueManager(inventory=inventory, variable_manager=variable_manager, loader=loader, options=options, passwords=self.passwords)
File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_queue_manager.py", line 104, in __init__
self._final_q = multiprocessing.Queue()
File "/usr/lib/python2.7/multiprocessing/__init__.py", line 218, in Queue
return Queue(maxsize)
File "/usr/lib/python2.7/multiprocessing/queues.py", line 63, in __init__
self._rlock = Lock()
File "/usr/lib/python2.7/multiprocessing/synchronize.py", line 147, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1)
File "/usr/lib/python2.7/multiprocessing/synchronize.py", line 75, in __init__
sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 38] Function not implemented

# Fixed code
def __init__(
    self,
    inventory,
    variable_manager,
    loader,
    options,
    passwords,
    stdout_callback=None,
    run_additional_callbacks=True,
    run_tree=False,
):
    self._inventory = inventory
    self._variable_manager = variable_manager
    self._loader = loader
    self._options = options
    self._stats = AggregateStats()
    self.passwords = passwords
    self._stdout_callback = stdout_callback
    self._run_additional_callbacks = run_additional_callbacks
    self._run_tree = run_tree

    self._callbacks_loaded = False
    self._callback_plugins = []
    self._start_at_done = False

    # make sure any module paths (if specified) are added to the module_loader
    if options.module_path:
        for path in options.module_path:
            if path:
                module_loader.add_directory(path)

    # a special flag to help us exit cleanly
    self._terminated = False

    # this dictionary is used to keep track of notified handlers
    self._notified_handlers = dict()
    self._listening_handlers = dict()

    # dictionaries to keep track of failed/unreachable hosts
    self._failed_hosts = dict()
    self._unreachable_hosts = dict()

    try:
        self._final_q = multiprocessing.Queue()
    except OSError as e:
        raise AnsibleError(
            "Unable to use multiprocessing, this is normally caused by lack of access to /dev/shm: %s"
            % to_native(e)
        )

    # A temporary file (opened pre-fork) used by connection
    # plugins for inter-process locking.
    self._connection_lockfile = tempfile.TemporaryFile()