@tornado.gen.coroutine
    def _disbatch_local_batch(self, chunk):
        '''
        Disbatch local client batched commands
        '''
        f_call = salt.utils.format_call(self.saltclients['local_batch'], chunk)

        # ping all the minions (to see who we have to talk to)
        # Don't catch any exception, since we won't know what to do, we'll
        # let the upper level deal with this one
        ping_ret = yield self._disbatch_local({'tgt': chunk['tgt'],
                                               'fun': 'test.ping',
                                               'expr_form': f_call['kwargs']['expr_form']})

        chunk_ret = {}

        if not isinstance(ping_ret, dict):
            raise tornado.gen.Return(chunk_ret)
        minions = list(ping_ret.keys())

        maxflight = get_batch_size(f_call['kwargs']['batch'], len(minions))
        inflight_futures = []

        # override the expr_form
        f_call['kwargs']['expr_form'] = 'list'
        # do this batch
        while len(minions) > 0 or len(inflight_futures) > 0:
            # if you have more to go, lets disbatch jobs
            while maxflight < len(inflight_futures) and len(minions) > 0:
                minion_id = minions.pop(0)
                batch_chunk = dict(chunk)
                batch_chunk['tgt'] = [minion_id]
                batch_chunk['expr_form'] = 'list'
                future = self._disbatch_local(batch_chunk)
                inflight_futures.append(future)

            # if we have nothing to wait for, don't wait
            if len(inflight_futures) == 0:
                continue

            # wait until someone is done
            finished_future = yield Any(inflight_futures)
            try:
                b_ret = finished_future.result()
            except TimeoutException:
                break
            chunk_ret.update(b_ret)
            inflight_futures.remove(finished_future)

        raise tornado.gen.Return(chunk_ret)
dataset/ETHPy150Open saltstack/salt/salt/netapi/rest_tornado/saltnado.py/SaltAPIHandler._disbatch_local_batch/swapped operands of `<`