Permalink
Browse files

fixed sync lib to munch up trailing breaks so we can send the same ha…

…ndler more than one message
  • Loading branch information...
1 parent edb1c61 commit ff0362b6de1cc3a7c20ced1af958a52902ba5904 @sirpengi sirpengi committed with javisantana Sep 28, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 varnish.py
View
@@ -27,11 +27,17 @@ def fetch(self, command):
"""
logging.debug('SENT: %s: %s' % (self.host, command))
self.write('%s\n' % command)
- (status, length), content = map(int, self.read_until('\n').split()), ''
- assert status == 200, 'Bad response code: %s %s' % (status, self.read_until('\n').rstrip())
+ while 1:
+ buffer = self.read_until('\n').strip()
+ if len(buffer):
+ break
+ status, length = map(int, buffer.split())
+ content = ''
+ assert status == 200, 'Bad response code: {status} {text} ({command})'.format(status=status, text=self.read_until('\n').strip(), command=command)
while len(content) < length:
content += self.read_until('\n')
logging.debug('RECV: %s: %dB %s' % (status,length,content[:30]))
+ self.read_eager()
return (status, length), content
# Service control methods

0 comments on commit ff0362b

Please sign in to comment.