Example #1
0
    def handleTimer(self, signum, frame):
        logging.debug("Scheduler tick")
        for i in Config.getsites():
            logging.debug(i)

        if not self.wpc:
            if self.logonce:
                logging.info("No workers connected.")
                self.logonce = False
            signal.alarm(self.period)
            return
        self.logonce = True

        for site in Config.getsites():
            if site.shouldSend(): #NOTE: You can call this once and ONLY ONCE, in every scheduler round
                try:
                    x = self.wpciter.next()
                except StopIteration:
                    self.wpciter = iter(self.wpc)
                    x = self.wpciter.next()

                site.sendMe(x)
                logging.debug("Sent \"%s\" to %s:%s" % (site.getName(), x.getpeername()[0], x.getpeername()[1]))
        signal.alarm(self.period)
Example #2
0
 def found_terminator(self):
     x = cPickle.loads("".join(self.data))
     Config.getsites()[x.getId()].setResult(x)
     self.data = []
     logging.info("%s: URL: %s Status: %s Loadtime: %.0f ms" % (x.getName(), x.getURL(), x.getStatus(), x.getLoadTime()))