1
# oops-repository is Copyright 2011 Canonical Ltd.
3
# Canonical Ltd ("Canonical") distributes the oops-repository source code under
4
# the GNU Affero General Public License, version 3 ("AGPLv3"). See the file
5
# LICENSE in the source tree for more information.
7
"""Things to ease working with cassandra."""
9
from pycassa.cassandra.Cassandra import InvalidRequestException
11
def workaround_1779(callable, *args, **kwargs):
12
"""Workaround cassandra not being able to do concurrent schema edits.
14
The callable is tried until it does not raised InvalidRequestException
15
with why = "Previous version mismatch. cannot apply."
17
:param callable: The callable to call.
18
:param args: The args for it.
19
:param kwargs: The kwargs for it.
20
:return: The result of calling the callable.
23
# Workaround https://issues.apache.org/jira/browse/CASSANDRA-1779:
24
# Cassandra cannot do concurrent schema changes.
26
return callable(*args, **kwargs)
28
except InvalidRequestException as e:
29
if e.why != 'Previous version mismatch. cannot apply.':