Пример #1
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        tick_min=False
        tick_hour=False
        tick_day=False
        tick_second = (self.tick_count % self.ticks_second) == 0 
        self.tick_count += 1
        
        if tick_second:
            self.sec_count += 1

            tick_min=(self.sec_count % 60)==0
            if tick_min:
                self.min_count += 1
                
                tick_hour=(self.min_count % 60)==0
                if tick_hour:
                    self.hour_count += 1
                    
                    tick_day=(self.hour_count % 24)==0
                    if tick_day:
                        self.day_count += 1
        
        #print "tick! ", tick_second
        mswitch.publish("__main__", "__tick__", self.ticks_second, 
                        tick_second, tick_min, tick_hour, tick_day, 
                        self.sec_count, self.min_count, self.hour_count, self.day_count)
        
        #(src_agent, agent_name, agent_id, 
        #  interest_map, responsesInterestList, 
        #  iq, isq, processor, low_priority_burst_size=5)
        quit=process_queues(False, self, "__main__", "__main__", 
                       self.interests, self.responsesInterests,
                       self.iq, self.isq, message_processor 
                       )
        ## for gobject... just in case
        return True
Пример #2
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        tick_min = False
        tick_hour = False
        tick_day = False
        tick_second = (self.tick_count % self.ticks_second) == 0
        self.tick_count += 1

        if tick_second:
            self.sec_count += 1

            if (self.sec_count % self.REFRESH_TIMEOUT) == 0:
                self.refreshUi()

            tick_min = (self.sec_count % 60) == 0
            if tick_min:
                self.min_count += 1

                tick_hour = (self.min_count % 60) == 0
                if tick_hour:
                    self.hour_count += 1

                    tick_day = (self.hour_count % 24) == 0
                    if tick_day:
                        self.day_count += 1

        # print "tick! ", tick_second
        mswitch.publish(
            "__main__",
            "__tick__",
            self.ticks_second,
            tick_second,
            tick_min,
            tick_hour,
            tick_day,
            self.sec_count,
            self.min_count,
            self.hour_count,
            self.day_count,
        )

        # (src_agent, agent_name, agent_id,
        #  interest_map, responsesInterestList,
        #  iq, isq, processor, low_priority_burst_size=5)
        quit = process_queues(
            self, "__main__", "__main__", self.interests, self.responsesInterests, self.iq, self.isq, message_processor
        )
        if quit:
            self.on_destroy()

        """
        while True:
            try:     
                envelope=self.isq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.isq))
                if quit:
                    self.on_destroy()
                    break
                
            except Empty:
                break
            continue            
        
        burst=self.LOW_PRIORITY_MESSAGE_BURST_SIZE
        
        while True:
            try:     
                envelope=self.iq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.iq))
                if quit:
                    self.on_destroy()
                    break
                    
                burst -= 1
                if burst == 0:
                    break
            except Empty:
                break
            
            continue
        """
        ## for gobject... just in case
        return True
Пример #3
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        tick_min = False
        tick_hour = False
        tick_day = False
        tick_second = (self.tick_count % self.ticks_second) == 0
        self.tick_count += 1

        if tick_second:
            self.sec_count += 1

            if (self.sec_count % self.REFRESH_TIMEOUT) == 0:
                self.refreshUi()

            tick_min = (self.sec_count % 60) == 0
            if tick_min:
                self.min_count += 1

                tick_hour = (self.min_count % 60) == 0
                if tick_hour:
                    self.hour_count += 1

                    tick_day = (self.hour_count % 24) == 0
                    if tick_day:
                        self.day_count += 1

        #print "tick! ", tick_second
        mswitch.publish("__main__", "__tick__", self.ticks_second, tick_second,
                        tick_min, tick_hour, tick_day, self.sec_count,
                        self.min_count, self.hour_count, self.day_count)

        #(src_agent, agent_name, agent_id,
        #  interest_map, responsesInterestList,
        #  iq, isq, processor, low_priority_burst_size=5)
        quit = process_queues(self, "__main__", "__main__", self.interests,
                              self.responsesInterests, self.iq, self.isq,
                              message_processor)
        if quit:
            self.on_destroy()
        """
        while True:
            try:     
                envelope=self.isq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.isq))
                if quit:
                    self.on_destroy()
                    break
                
            except Empty:
                break
            continue            
        
        burst=self.LOW_PRIORITY_MESSAGE_BURST_SIZE
        
        while True:
            try:     
                envelope=self.iq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.iq))
                if quit:
                    self.on_destroy()
                    break
                    
                burst -= 1
                if burst == 0:
                    break
            except Empty:
                break
            
            continue
        """
        ## for gobject... just in case
        return True