'Wait for the shared counter to drop to zero, using a short sleep
between checks to ensure we don\'t spin lock'

def _wait_on_pending_results(self, iterator):

    ret_results = []
    display.debug('waiting    for    pending    results...')
    while ((self._pending_results > 0) and (not self._tqm._terminated)):
        if self._tqm.has_dead_workers():
            raise AnsibleError('A    worker    was    found    in    a    dead    state')
        results = self._process_pending_results(iterator)
        ret_results.extend(results)
        if (self._pending_results > 0):
            time.sleep(C.DEFAULT_INTERNAL_POLL_INTERVAL)
    display.debug('no    more    pending    results,    returning    what    we    have')
    return ret_results
