in pyqldb/cursor/read_ahead_cursor.py [0:0]
def _populate_queue(self):
"""
Fill the buffer queue with the statement_result fetched. If ClientError is received, it is put in the queue and
execution stops. If the parent transaction is closed, stop fetching results.
"""
try:
next_page_token = self._page.get('NextPageToken')
while next_page_token is not None:
statement_result = self._session._fetch_page(self._transaction_id, next_page_token)
while True:
try:
# Timeout of 50ms.
self._queue.put(statement_result, timeout=0.05)
page = statement_result.get('Page')
next_page_token = page.get('NextPageToken')
break
except Full:
# When timeout is reached, check if the read-ahead retrieval thread should end.
if not self._is_open:
logger.debug('Cursor was closed; read-ahead retriever thread stopping.')
raise ResultClosedError(self._session.token)
except (ClientError, ResultClosedError) as error:
while not self._queue.empty():
self._queue.get_nowait()
logger.debug('Queued an exception: {}'.format(error))
self._queue.put(error)