Ejemplo n.º 1
0
    def process(self):
        announce_timer = pylib_generic.timer(0)
        check_load_timer = pylib_generic.timer(0)
        load_ok = True

        while True:
            if announce_timer.expired():
                if self.config.mode == "announce":
                    self.announce()
                elif self.config.mode == "connect":
                    self.connect()

                announce_timer.set(10.0)

            if check_load_timer.expired():
                load_ok = self.check_load()
                check_load_timer.set(30.0)

            ractive = [self.server]+self.running+\
                      [i for i in self.connections if i.readable()]
            wactive = [i for i in self.connections if i.sendable()]
            ready = select.select(ractive, wactive, [], 1)

            for i in ready[0]:
                if i == self.server:
                    new_conn = self.server.accept(pylib_tcp.jobend_re)
                    pylib_io.verbout("New connection " + str(new_conn))
                    self.connections.append(new_conn)

                if i in self.connections:
                    commands = i.read()
                    for command in commands:
                        if command == "":
                            pylib_io.verbout("Connection " + str(i) +
                                             " terminated")
                            self.connections.remove(i)
                        else:
                            self.dispatch(i, command)

                if i in self.running:
                    if i.check_and_report():
                        self.running.remove(i)

            for i in ready[1]:
                i.send()

            if len(self.running) < self.max_jobs() and load_ok:
                self.run_job()
Ejemplo n.º 2
0
    def process(self):
        announce_timer = pylib_generic.timer(0)
        check_load_timer = pylib_generic.timer(0)
        load_ok = True
        
        while True:
            if announce_timer.expired():
                if self.config.mode == "announce":
                    self.announce()
                elif self.config.mode == "connect":
                    self.connect()
                
                announce_timer.set(10.0)

            if check_load_timer.expired():
                load_ok = self.check_load()                
                check_load_timer.set(30.0)
                        
            ractive = [self.server]+self.running+\
                      [i for i in self.connections if i.readable()]
            wactive = [i for i in self.connections if i.sendable()]
            ready   = select.select(ractive, wactive, [], 1)

            for i in ready[0]:
                if i == self.server:
                    new_conn =  self.server.accept(pylib_tcp.jobend_re)
                    pylib_io.verbout("New connection "+str(new_conn))
                    self.connections.append(new_conn)

                if i in self.connections:
                    commands = i.read()
                    for command in commands:
                        if command == "":
                            pylib_io.verbout("Connection "+str(i)+" terminated")
                            self.connections.remove(i)
                        else:
                            self.dispatch(i, command)

                if i in self.running:
                    if i.check_and_report():
                        self.running.remove(i)
                        
            for i in ready[1]:
                i.send()

            if len(self.running) < self.max_jobs() and load_ok:
                self.run_job()
Ejemplo n.º 3
0
 def __init__(self, name, auto_sync=None):
     self.name = e_strip_name(name)
     self.prot = eprot(name)
     self.spec = espec(name)
     self.job_complete = False
     self.auto_sync = auto_sync
     self.specdir = None
     self.protdir = None
     self.retired = pylib_generic.timer(0)
     self.refresh()
Ejemplo n.º 4
0
 def __init__(self, name, auto_sync = None):
     self.name          = e_strip_name(name)
     self.prot          = eprot(name)
     self.spec          = espec(name)
     self.job_complete  = False
     self.auto_sync     = auto_sync
     self.specdir       = None
     self.protdir       = None
     self.retired       = pylib_generic.timer(0)
     self.refresh()