'Function to submit request to the executor and queue the `Future` objects.'

def _run(self):

    sequence = list(range(len(self.sequence)))
    while True:
        if self.shuffle:
            random.shuffle(sequence)
        for i in sequence:
            if self.stop_signal.is_set():
                return
            self.queue.put(self.executor.apply_async(get_index, (self.sequence, i)), block=True)
        self.sequence.on_epoch_end()
