##// END OF EJS Templates
wireproto: optimize handling of large batch responses...
Augie Fackler -
r29151:7996c3ac default
parent child Browse files
Show More
@@ -231,17 +231,19 b' class wirepeer(peer.peerrepository):'
231 for k, v in argsdict.iteritems())
231 for k, v in argsdict.iteritems())
232 cmds.append('%s %s' % (op, args))
232 cmds.append('%s %s' % (op, args))
233 rsp = self._callstream("batch", cmds=';'.join(cmds))
233 rsp = self._callstream("batch", cmds=';'.join(cmds))
234 # TODO this response parsing is probably suboptimal for large
234 chunk = rsp.read(1024)
235 # batches with large responses.
235 work = [chunk]
236 work = rsp.read(1024)
237 chunk = work
238 while chunk:
236 while chunk:
239 while ';' in work:
237 while ';' not in chunk and chunk:
240 one, work = work.split(';', 1)
238 chunk = rsp.read(1024)
239 work.append(chunk)
240 merged = ''.join(work)
241 while ';' in merged:
242 one, merged = merged.split(';', 1)
241 yield unescapearg(one)
243 yield unescapearg(one)
242 chunk = rsp.read(1024)
244 chunk = rsp.read(1024)
243 work += chunk
245 work = [merged, chunk]
244 yield unescapearg(work)
246 yield unescapearg(''.join(work))
245
247
246 def _submitone(self, op, args):
248 def _submitone(self, op, args):
247 return self._call(op, **args)
249 return self._call(op, **args)
General Comments 0
You need to be logged in to leave comments. Login now