summaryrefslogtreecommitdiff
path: root/heat/db/utils.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-04-07 17:46:50 +0000
committerGerrit Code Review <review@openstack.org>2023-04-07 17:46:50 +0000
commitcec8eb12c628a38b2431dac78ed37fc3f1506939 (patch)
treef613061baee36e32de818128e96f6d5742112585 /heat/db/utils.py
parent1ca04117b9c3bff0b338df97df2c26d6a70929ea (diff)
parent43a5f3984e433ec28616cfe98cb060d9ff51af58 (diff)
downloadheat-cec8eb12c628a38b2431dac78ed37fc3f1506939.tar.gz
Merge "db: Remove layer of indirection"
Diffstat (limited to 'heat/db/utils.py')
-rw-r--r--heat/db/utils.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/heat/db/utils.py b/heat/db/utils.py
new file mode 100644
index 000000000..67e2d541e
--- /dev/null
+++ b/heat/db/utils.py
@@ -0,0 +1,25 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# SQLAlchemy helper functions
+
+from sqlalchemy.orm import exc
+import tenacity
+
+
+def retry_on_stale_data_error(func):
+ wrapper = tenacity.retry(
+ stop=tenacity.stop_after_attempt(3),
+ retry=tenacity.retry_if_exception_type(exc.StaleDataError),
+ reraise=True)
+ return wrapper(func)