From 8a27521bf9a80411f46a600751329e92e43fccf9 Mon Sep 17 00:00:00 2001 From: Wouter Bolsterlee Date: Mon, 24 Nov 2014 23:16:46 +0100 Subject: Correctly handle scanner that are smaller than expected Fixes #72. --- happybase/table.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'happybase/table.py') diff --git a/happybase/table.py b/happybase/table.py index 60e74be..ac897d2 100644 --- a/happybase/table.py +++ b/happybase/table.py @@ -389,6 +389,9 @@ class Table(object): items = self.connection.client.scannerGetList( scan_id, how_many) + if not items: + break # scan has finished + n_fetched += len(items) for n_returned, item in enumerate(items, n_returned + 1): @@ -401,11 +404,7 @@ class Table(object): yield item.row, row if limit is not None and n_returned == limit: - return - - # Avoid round-trip when exhausted - if len(items) < how_many: - break + break # not interested in the remainder finally: self.connection.client.scannerClose(scan_id) logger.debug( -- cgit v1.2.1