equal
deleted
inserted
replaced
40 self.fout.write(v) |
40 self.fout.write(v) |
41 self.fout.flush() |
41 self.fout.flush() |
42 |
42 |
43 def serve_forever(self): |
43 def serve_forever(self): |
44 try: |
44 try: |
45 while self.serve_one(): pass |
45 while self.serve_one(): |
|
46 pass |
46 finally: |
47 finally: |
47 if self.lock is not None: |
48 if self.lock is not None: |
48 self.lock.release() |
49 self.lock.release() |
49 sys.exit(0) |
50 sys.exit(0) |
50 |
51 |
51 def serve_one(self): |
52 def serve_one(self): |
52 cmd = self.fin.readline()[:-1] |
53 cmd = self.fin.readline()[:-1] |
53 if cmd: |
54 if cmd: |
54 impl = getattr(self, 'do_' + cmd, None) |
55 impl = getattr(self, 'do_' + cmd, None) |
55 if impl: impl() |
56 if impl: |
|
57 impl() |
56 else: self.respond("") |
58 else: self.respond("") |
57 return cmd != '' |
59 return cmd != '' |
58 |
60 |
59 def do_lookup(self): |
61 def do_lookup(self): |
60 arg, key = self.getarg() |
62 arg, key = self.getarg() |