Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _invalid_state(self, state):
raise errors.InternalError(
"connection state must be %s, is %s" % (state, self._state))
def _fill_cache(self):
self._lock.acquire()
try:
if self._cached_rows:
raise InternalError("attempt to fill cache that isn't empty")
end_of_data, rows = self.c.fetch_rows(
self._portal_name, self.row_cache_size, self._row_desc)
self._cached_rows = rows
if end_of_data:
self._command_complete = True
finally:
self._lock.release()
def __init__(self, typ, name):
if len(typ) != 1:
raise errors.InternalError("Describe typ must be 1 char")
self.typ = typ
self.name = name
def query_with_catch(cursor, query):
try:
cursor.execute(query)
except pg8000.errors.InternalError as e:
print >> stderr, "Received error from pg8000: %s" % e
print >> stderr, "Attempting to continue..."
def _get_row_count(self):
self._lock.acquire()
try:
if not self._command_complete:
end_of_data, rows = self.c.fetch_rows(
self._portal_name, 0, self._row_desc)
self._cached_rows += rows
if end_of_data:
self._command_complete = True
else:
raise InternalError(
"fetch_rows(0) did not hit end of data")
return self._ongoing_row_count + len(self._cached_rows)
finally:
self._lock.release()