File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,10 @@ def retry_wrapper(*args, **kwargs):
82
82
result = yield result
83
83
except exceptions .NestedRetryException as e :
84
84
error = e
85
- except Exception as e :
85
+ except BaseException as e :
86
86
# `e` is removed from locals at end of block
87
87
error = e # See: https://goo.gl/5J8BMK
88
+
88
89
if not is_transient_error (error ):
89
90
# If we are in an inner retry block, use special nested
90
91
# retry exception to bubble up to outer retry. Else, raise
@@ -104,6 +105,10 @@ def retry_wrapper(*args, **kwargs):
104
105
105
106
yield tasklets .sleep (sleep_time )
106
107
108
+ # Unknown errors really want to show up as None, so manually set the error.
109
+ if isinstance (error , core_exceptions .Unknown ):
110
+ error = "google.api_core.exceptions.Unknown"
111
+
107
112
raise core_exceptions .RetryError (
108
113
"Maximum number of {} retries exceeded while calling {}" .format (
109
114
retries , callback
Original file line number Diff line number Diff line change @@ -98,6 +98,18 @@ def callback():
98
98
retry = _retry .retry_async (callback )
99
99
assert retry ().exception () is error
100
100
101
+ @staticmethod
102
+ @pytest .mark .usefixtures ("in_context" )
103
+ def test_api_core_unknown ():
104
+ def callback ():
105
+ raise core_exceptions .Unknown ("Unknown" )
106
+
107
+ with pytest .raises (core_exceptions .RetryError ) as e :
108
+ retry = _retry .retry_async (callback , retries = 1 )
109
+ retry ().result ()
110
+
111
+ assert e .value .cause == "google.api_core.exceptions.Unknown"
112
+
101
113
@staticmethod
102
114
@pytest .mark .usefixtures ("in_context" )
103
115
@mock .patch ("google.cloud.ndb.tasklets.sleep" )
You can’t perform that action at this time.
0 commit comments