(self, repeats: Iterable[int], trial_fn: Any, args: Any)
Lazily generate results from an executor without submitting all jobs at once.
Lazily generate results from an executor without submitting all jobs at once.
Lazily generate results from an executor without submitting all jobs at once .
def _gen_results_parallel(self, repeats: Iterable[int], trial_fn: Any, args: Any) -> Generator[Any, None, None]:
        """Lazily generate results from an executor without submitting all jobs at once."""
        self._futures = deque()

        # the idea here is to submit at least ``pre_dispatch`` jobs *before* we
        # yield any results, then do both in tandem, before draining the queue
        for r in repeats:
            if len(self._futures) < self.pre_dispatch:
                self._futures.append(self._executor.submit(trial_fn, r, *args))
                continue
            yield self._futures.popleft().result()

        while self._futures:
            yield self._futures.popleft().result()
def _gen_results_parallel ( self , repeats : Iterable [ int ] , trial_fn : Any , args : Any ) -> Generator [ Any , None , None ] : self . _futures = deque ( ) # the idea here is to submit at least ``pre_dispatch`` jobs *before* we # yield any results, then do both in tandem, before draining the queue for r in repeats : if len ( self . _futures ) < self . pre_dispatch : self . _futures . append ( self . _executor . submit ( trial_fn , r , * args ) ) continue yield self . _futures . popleft ( ) . result ( ) while self . _futures : yield self . _futures . popleft ( ) . result ( )