def action(self): data = self.recv() if data: self.sink.setNext(data) self.counter += 1 debugout(self, "counter", self.counter) if self.counter == self.max: Task.shutdown.set() self.notify()
def start(self): assert self.proc == None, "application already started" cmdline = [self.command] for k, v in self.params: cmdline.append("-" + k) cmdline.append(str(v)) debugout("starting application", cmdline) self.proc = subprocess.Popen(cmdline)
def wait(self): debugout("waiting for application to quit") self.proc.wait()
def createSocket(self): s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) debugout(self, "accessing socket", self.fn) s.connect(self.fn) self.sock = s
def __init__(self, fn): Socket.__init__(self, fn) self.lsock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.lsock.bind(self.fn) self.lsock.listen(1) debugout(self, "socket created", self.fn)
def join(self): debugout(self, "joining...") Thread.join(self) debugout(self, "joined")
def sync(self): debugout(self, "syncing...") self.setup.wait() debugout(self, "synced")
def start(self): debugout(self, "starting...") Thread.start(self) debugout(self, "started")