[ARVADOS] updated: 42beb8f600402b8d6ee69b0aea100cc7d8feeff3

git at public.curoverse.com git at public.curoverse.com
Fri Oct 24 19:19:08 EDT 2014


Summary of changes:
 sdk/python/arvados/stream.py | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

       via  42beb8f600402b8d6ee69b0aea100cc7d8feeff3 (commit)
      from  6527508bc378867fd4d5e1af20ffd7868cec5f62 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 42beb8f600402b8d6ee69b0aea100cc7d8feeff3
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Oct 24 19:10:50 2014 -0400

    3603: Fixup cruft I added during development.

diff --git a/sdk/python/arvados/stream.py b/sdk/python/arvados/stream.py
index f958ead..f5b283a 100644
--- a/sdk/python/arvados/stream.py
+++ b/sdk/python/arvados/stream.py
@@ -104,7 +104,6 @@ class StreamFileReader(ArvadosFileBase):
         super(StreamFileReader, self).__init__(self.NameAttribute(name), 'rb')
         self._stream = stream
         self.segments = segments
-        self._max_segsize = max(seg[1] for seg in segments)
         self._filepos = 0L
         self.num_retries = stream.num_retries
         self._readline_cache = (-1, None, None)
@@ -166,9 +165,7 @@ class StreamFileReader(ArvadosFileBase):
 
     @ArvadosFileBase._before_close
     @retry_method
-    def readall(self, size=None, num_retries=None):
-        if size is None:
-            size = self._max_segsize
+    def readall(self, size=2**20, num_retries=None):
         while True:
             data = self.read(size, num_retries=num_retries)
             if data == '':
@@ -178,16 +175,15 @@ class StreamFileReader(ArvadosFileBase):
     @ArvadosFileBase._before_close
     @retry_method
     def readline(self, read_iter=None, num_retries=None):
-        cache_usable = ((self.tell() == self._readline_cache[0]) and
-                        ((read_iter is None) or
-                         (read_iter is self._readline_cache[1])))
-        data = []
-        if cache_usable:
+        if (((read_iter is None) or (read_iter is self._readline_cache[1])) and
+              (self.tell() == self._readline_cache[0])):
             read_iter = self._readline_cache[1]
-            data.append(self._readline_cache[2])
-        elif read_iter is None:
-            read_iter = self.readall(num_retries=num_retries)
-        while (not data) or ('\n' not in data[-1]):
+            data = [self._readline_cache[2]]
+        else:
+            if read_iter is None:
+                read_iter = self.readall_decompressed(num_retries=num_retries)
+            data = ['']
+        while '\n' not in data[-1]:
             try:
                 data.append(next(read_iter))
             except StopIteration:
@@ -210,9 +206,7 @@ class StreamFileReader(ArvadosFileBase):
 
     @ArvadosFileBase._before_close
     @retry_method
-    def readall_decompressed(self, size=None, num_retries=None):
-        if size is None:
-            size = self._max_segsize
+    def readall_decompressed(self, size=2**20, num_retries=None):
         self.seek(0)
         if re.search('\.bz2$', self.name):
             dc = bz2.BZ2Decompressor()

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list