Skip to content

Commit

Permalink
Document retry of exceptions while streaming 'read'/'execute_sql' res…
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver authored and landrito committed Aug 22, 2017
1 parent 7ced18b commit 88b3904
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions docs/spanner/snapshot-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,24 @@ fails if the result set is too large,

.. note::

If streaming a chunk fails due to a "resumable" error,
:meth:`Session.read` retries the ``StreamingRead`` API reqeust,
passing the ``resume_token`` from the last partial result streamed.
If streaming a chunk raises an exception, the application can
retry the ``read``, passing the ``resume_token`` from ``StreamingResultSet``
which raised the error. E.g.:

.. code:: python
result = snapshot.read(table, columns, keys)
while True:
try:
for row in result.rows:
print row
except Exception:
result = snapshot.read(
table, columns, keys, resume_token=result.resume_token)
continue
else:
break
Execute a SQL Select Statement
Expand Down Expand Up @@ -97,6 +112,26 @@ fails if the result set is too large,
manually, perform all iteration within the context of the
``with database.snapshot()`` block.

.. note::

If streaming a chunk raises an exception, the application can
retry the query, passing the ``resume_token`` from ``StreamingResultSet``
which raised the error. E.g.:

.. code:: python
result = snapshot.execute_sql(QUERY)
while True:
try:
for row in result.rows:
print row
except Exception:
result = snapshot.execute_sql(
QUERY, resume_token=result.resume_token)
continue
else:
break
Next Step
---------
Expand Down

0 comments on commit 88b3904

Please sign in to comment.