Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document retry of exceptions while streaming 'read'/'execute_sql' results #3790

Merged
merged 1 commit into from
Aug 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

This comment was marked as spam.

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