summaryrefslogtreecommitdiff
path: root/kazoo
diff options
context:
space:
mode:
authorJiangge Zhang <tonyseek@gmail.com>2017-02-25 17:11:12 +0800
committerJiangge Zhang <tonyseek@gmail.com>2017-02-25 17:11:40 +0800
commitbd5a1d363fc9f3e324f09a20a33733b835d4df0e (patch)
treeb9e7df643e1344e9d792897277e35bbbecb474a5 /kazoo
parentd1b07d3266c9bb22b352a1fba4abbfc181279d04 (diff)
downloadkazoo-bd5a1d363fc9f3e324f09a20a33733b835d4df0e.tar.gz
Use KazooException instead of RuntimeError in TreeCache
https://github.com/python-zk/kazoo/pull/398#discussion_r90782555
Diffstat (limited to 'kazoo')
-rw-r--r--kazoo/recipe/cache.py4
-rw-r--r--kazoo/tests/test_cache.py3
2 files changed, 4 insertions, 3 deletions
diff --git a/kazoo/recipe/cache.py b/kazoo/recipe/cache.py
index 71611a6..6761731 100644
--- a/kazoo/recipe/cache.py
+++ b/kazoo/recipe/cache.py
@@ -19,7 +19,7 @@ import contextlib
import functools
import operator
-from kazoo.exceptions import NoNodeError
+from kazoo.exceptions import NoNodeError, KazooException
from kazoo.protocol.states import KazooState, EventType
@@ -63,7 +63,7 @@ class TreeCache(object):
if self._state == self.STATE_LATENT:
self._state = self.STATE_STARTED
else:
- raise RuntimeError('already started')
+ raise KazooException('already started')
self._client.add_listener(self._session_watcher)
self._client.ensure_path(self._root._path)
diff --git a/kazoo/tests/test_cache.py b/kazoo/tests/test_cache.py
index c0d8a67..dda60a8 100644
--- a/kazoo/tests/test_cache.py
+++ b/kazoo/tests/test_cache.py
@@ -4,6 +4,7 @@ from mock import patch, call, Mock
from nose.tools import eq_, ok_, assert_not_equal, raises
from kazoo.testing import KazooTestCase
+from kazoo.exceptions import KazooException
from kazoo.recipe.cache import TreeCache, TreeNode, TreeEvent
@@ -60,7 +61,7 @@ class KazooTreeCacheTests(KazooTestCase):
eq_(self.cache._state, TreeCache.STATE_STARTED)
eq_(self.cache._root._state, TreeNode.STATE_LIVE)
- @raises(RuntimeError)
+ @raises(KazooException)
def test_start_twice(self):
self.make_cache()
self.cache.start()