def __init__(self, userid, modules): self.userid = userid self.here, self.there = Pipe(duplex=True) self.proc = CoqProc() self.proc.start(modules) self.read() logging.debug("Coqtop Process started %s", self.proc)
class ActiveConn(object): """ Talks to the specific backend instance associated with a userid """ def __init__(self, userid, modules): self.userid = userid self.here, self.there = Pipe(duplex=True) self.proc = CoqProc() self.proc.start(modules) self.read() logging.debug("Coqtop Process started %s", self.proc) def read(self): """poll results from the coqtop backend""" res = None self.proc.run(self.there) if self.here.poll(): res = self.here.recv() logging.debug("Received content from process") return {'userid': self.userid, 'response': res} def send(self, data): """send results to our coqtop instance""" if self.proc.alive: logging.debug("sending stuff") self.here.send(data + " ") return True else: return False def quit(self): if self.proc.alive: return self.proc.terminate(True)