|
|
@@ -144,6 +144,7 @@ class Client(object): |
|
|
|
ctx = StreamInserter(self, path, start, end) |
|
|
|
yield ctx |
|
|
|
ctx.finalize() |
|
|
|
ctx.destroy() |
|
|
|
|
|
|
|
def stream_insert(self, path, data, start = None, end = None): |
|
|
|
"""Insert rows of data into a stream. data should be a string |
|
|
@@ -293,6 +294,15 @@ class StreamInserter(object): |
|
|
|
self._block_data = [] |
|
|
|
self._block_len = 0 |
|
|
|
|
|
|
|
self.destroyed = False |
|
|
|
|
|
|
|
def destroy(self): |
|
|
|
"""Ensure this object can't be used again without raising |
|
|
|
an error""" |
|
|
|
def error(*args, **kwargs): |
|
|
|
raise Exception("don't reuse this context object") |
|
|
|
self._send_block = self.insert = self.finalize = self.send = error |
|
|
|
|
|
|
|
def insert(self, data): |
|
|
|
"""Insert a chunk of ASCII formatted data in string form. The |
|
|
|
overall data must consist of lines terminated by '\\n'.""" |
|
|
|