File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ def start(self):
6262 """
6363 if self ._state == self .STATE_LATENT :
6464 self ._state = self .STATE_STARTED
65+ elif self ._state == self .STATE_CLOSED :
66+ raise KazooException ('already closed' )
6567 else :
6668 raise KazooException ('already started' )
6769
@@ -77,6 +79,9 @@ def close(self):
7779 A closed cache was detached from ZooKeeper's changes. And all nodes
7880 will be invalidated.
7981
82+ Once a tree cache was closed, it could not be started again. You should
83+ only close a tree cache while you want to recycle it.
84+
8085 .. note::
8186
8287 This method is not thread safe.
Original file line number Diff line number Diff line change @@ -62,10 +62,17 @@ def test_start(self):
6262 eq_ (self .cache ._root ._state , TreeNode .STATE_LIVE )
6363
6464 @raises (KazooException )
65- def test_start_twice (self ):
65+ def test_start_started (self ):
6666 self .make_cache ()
6767 self .cache .start ()
6868
69+ @raises (KazooException )
70+ def test_start_closed (self ):
71+ self .make_cache ()
72+ self .cache .start ()
73+ self .cache .close ()
74+ self .cache .start ()
75+
6976 def test_close (self ):
7077 self .make_cache ()
7178 self .wait_cache (since = TreeEvent .INITIALIZED )
You can’t perform that action at this time.
0 commit comments