def _checkActive(self):
        while self.getActive() < self.max_simul_reqs and self.getPending() > 0:     
            hosts = self.pending_reqs.keys()
            dispatched_requests = False
            for host in hosts:
                if len(self.pending_reqs[host]) == 0:
                    del self.pending_reqs[host]
                elif self._hostRequestCheck(host):
                    dispatched_requests = True
                    req = self.pending_reqs[host].pop(0)
                    d = self._getPage(req)
                    d.addCallback(self._requestComplete, req["deferred"], host)
                    d.addErrback(self._requestError, req["deferred"], host)
                    self.last_req[host] = time.time()
                    self.active_reqs[host] = self.active_reqs.get(host, 0) + 1
            if not dispatched_requests:
                break
        if self.getPending() > 0:
            reactor.callLater(.1, self._checkActive)
dataset/ETHPy150Open wehriam/awspider/awspider/requestqueuer.py/RequestQueuer._checkActive/original