# # # patch "monotone.py" # from [4800fb3c8a713d9a959ca4ec9823306469860dc1] # to [d29711cd1c0d4ac4e3f48ca98444bba31f25a399] # ============================================================ --- monotone.py 4800fb3c8a713d9a959ca4ec9823306469860dc1 +++ monotone.py d29711cd1c0d4ac4e3f48ca98444bba31f25a399 @@ -224,6 +224,8 @@ import popen2 import select from utility import set_nonblocking + +packet_header_re = re.compile(r'(\d+):(\d+):([lm]):(\d+):') class RecvPacket: "A packet received from monotone automate stdio" @@ -237,7 +239,7 @@ def process_data(self, data): self.buffer += data if self.length == None: - m = re.match(r'(\d+):(\d+):([lm]):(\d+):', data) + m = packet_header_re.match(data) if m: self.cmdnum, self.error, pstate, self.length = m.groups() self.length = int(self.length) @@ -262,6 +264,14 @@ self.command = "%s --db=%s automate stdio" % (self.mt, pipes.quote(self.dbfile)) #self.command = "/bin/cat" self.process = None + def __del__(self): + if self.process: + try: + self.process.tochild.close() + self.process.fromchild.close() + self.process.wait() + except: pass + self.process = None def start(self): self.process = popen2.Popen3(self.command) set_nonblocking(self.process.fromchild) @@ -294,3 +304,4 @@ # didn't parse r = RecvPacket(r.buffer) return result_code, result_string +