summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2014-01-26 16:05:07 -0800
committerGuido van Rossum <guido@python.org>2014-01-26 16:05:07 -0800
commit32d58d671448578ed6d47e86c5af887f5232b925 (patch)
tree2018e5a702b58f5fc378cba580933a867ac546cf /examples
parent80b908deb40ebcb4e54ff5e9dd8902b7a148f3ca (diff)
downloadtrollius-32d58d671448578ed6d47e86c5af887f5232b925.tar.gz
The standard readexactly() now raises on a short read, so kill the custom wrapper.
Diffstat (limited to 'examples')
-rw-r--r--examples/crawl.py24
1 files changed, 2 insertions, 22 deletions
diff --git a/examples/crawl.py b/examples/crawl.py
index f0c8e3d..b7333ce 100644
--- a/examples/crawl.py
+++ b/examples/crawl.py
@@ -412,26 +412,6 @@ class Response:
return default
@asyncio.coroutine
- def readexactly(self, nbytes):
- """Wrapper for readexactly() that raise EOFError if not enough data.
-
- This also logs (at the vvv level) while it is reading.
- """
- blocks = []
- nread = 0
- while nread < nbytes:
- self.log(3, 'reading block', len(blocks),
- 'with', nbytes - nread, 'bytes remaining')
- block = yield from self.reader.read(nbytes-nread)
- self.log(3, 'read', len(block), 'bytes')
- if not block:
- raise EOFError('EOF with %d more bytes expected' %
- (nbytes - nread))
- blocks.append(block)
- nread += len(block)
- return b''.join(blocks)
-
- @asyncio.coroutine
def read(self):
"""Read the response body.
@@ -456,7 +436,7 @@ class Response:
size = int(parts[0], 16)
if size:
self.log(3, 'reading chunk of', size, 'bytes')
- block = yield from self.readexactly(size)
+ block = yield from self.reader.readexactly(size)
assert len(block) == size, (len(block), size)
blocks.append(block)
crlf = yield from self.reader.readline()
@@ -472,7 +452,7 @@ class Response:
# TODO: Should make sure not to recycle the connection
# in this case.
else:
- body = yield from self.readexactly(nbytes)
+ body = yield from self.reader.readexactly(nbytes)
return body