Beispiel #1
0
 def _reset_state(self):
     self._buffer = []
     self._description = None
     if self._last_operation_active:
         self._last_operation_active = False
         rpc.close_operation(self.service, self._last_operation_handle)
     self._last_operation_string = None
     self._last_operation_handle = None
Beispiel #2
0
 def _reset_state(self):
     self._buffer = []
     self._description = None
     if self._last_operation_active:
         self._last_operation_active = False
         rpc.close_operation(self.service, self._last_operation_handle)
     self._last_operation_string = None
     self._last_operation_handle = None
Beispiel #3
0
 def _execute_sync(self, operation_fn):
     # operation_fn should set self._last_operation_string and
     # self._last_operation_handle
     self._reset_state()
     operation_fn()
     self._last_operation_active = True
     self._wait_to_finish()  # make execute synchronous
     if self.has_result_set:
         schema = rpc.get_result_schema(self.service,
                 self._last_operation_handle)
         self._description = [tup + (None, None, None, None, None) for tup in schema]
     else:
         self._last_operation_active = False
         rpc.close_operation(self.service, self._last_operation_handle)
Beispiel #4
0
 def _execute_sync(self, operation_fn):
     # operation_fn should set self._last_operation_string and
     # self._last_operation_handle
     self._reset_state()
     operation_fn()
     self._last_operation_active = True
     self._wait_to_finish()  # make execute synchronous
     if self.has_result_set:
         schema = rpc.get_result_schema(self.service,
                 self._last_operation_handle)
         self._description = [tup + (None, None, None, None, None) for tup in schema]
     else:
         self._last_operation_active = False
         rpc.close_operation(self.service, self._last_operation_handle)
Beispiel #5
0
 def next(self):
     if not self.has_result_set:
         raise ProgrammingError("Trying to fetch results on an operation with no results.")
     if len(self._buffer) > 0:
         return self._buffer.pop(0)
     elif self._last_operation_active:
         # self._buffer is empty here and op is active: try to pull more rows
         rows = rpc.fetch_results(self.service,
                 self._last_operation_handle, self.description,
                 self.buffersize)
         self._buffer.extend(rows)
         if len(self._buffer) == 0:
             self._last_operation_active = False
             rpc.close_operation(self.service, self._last_operation_handle)
             raise StopIteration
         return self._buffer.pop(0)
     else:
         # empty buffer and op is now closed: raise StopIteration
         raise StopIteration
Beispiel #6
0
 def next(self):
     if not self.has_result_set:
         raise ProgrammingError("Trying to fetch results on an operation with no results.")
     if len(self._buffer) > 0:
         return self._buffer.pop(0)
     elif self._last_operation_active:
         # self._buffer is empty here and op is active: try to pull more rows
         rows = rpc.fetch_results(self.service,
                 self._last_operation_handle, self.description,
                 self.buffersize)
         self._buffer.extend(rows)
         if len(self._buffer) == 0:
             self._last_operation_active = False
             rpc.close_operation(self.service, self._last_operation_handle)
             raise StopIteration
         return self._buffer.pop(0)
     else:
         # empty buffer and op is now closed: raise StopIteration
         raise StopIteration
Beispiel #7
0
 def close_operation(self):
     if self._last_operation_active:
         self._last_operation_active = False
         rpc.close_operation(self.service, self._last_operation_handle)
Beispiel #8
0
 def close_operation(self):
     if self._last_operation_active:
         self._last_operation_active = False
         rpc.close_operation(self.service, self._last_operation_handle)