Package gavo :: Package utils :: Module misctricks :: Class StreamBuffer
[frames] | no frames]

Class StreamBuffer

source code

object --+
         |
        StreamBuffer

a buffer that takes data in arbitrary chunks and returns them in chops of chunkSize bytes.

There's a lock in place so you can access add and get from different threads.

When everything is written, you must all doneWriting.

Instance Methods
 
__init__(self, chunkSize=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
add(self, data) source code
 
get(self, numBytes=None) source code
 
getToChar(self, char)
returns the the buffer up to the first occurrence of char.
source code
 
getRest(self)
returns the entire buffer as far as it is left over.
source code
 
doneWriting(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  chunkSize = 50000
Properties

Inherited from object: __class__

Method Details

__init__(self, chunkSize=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

getToChar(self, char)

source code 

returns the the buffer up to the first occurrence of char.

If char is not present in the buffer, the function returns None.