1
# Copyright (c) 2011 Canonical Ltd
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public
14
# License along with this program. If not, see
15
# <http://www.gnu.org/licenses/>.
17
"""Things to ease working with cassandra."""
19
from pycassa.pool import InvalidRequestError
22
def workaround_1779(callable, *args, **kwargs):
23
"""Workaround cassandra not being able to do concurrent schema edits.
25
The callable is tried until it does not raised InvalidRequestException
26
with why = "Previous version mismatch. cannot apply."
28
:param callable: The callable to call.
29
:param args: The args for it.
30
:param kwargs: The kwargs for it.
31
:return: The result of calling the callable.
34
# Workaround https://issues.apache.org/jira/browse/CASSANDRA-1779:
35
# Cassandra cannot do concurrent schema changes.
37
return callable(*args, **kwargs)
39
except InvalidRequestError as e:
40
if e.why != 'Previous version mismatch. cannot apply.':