-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in listener function can't call command such as 'exists, create, etc.' #405
Comments
maybe you should use try before 'if not zk.exists(child_path)' command , because all methods in zkclient will raise exception when something wrong in it, just like:
|
@luofeilong it's not that case, i have tried it. You can reproduce it easily.
i guess the problem is in zk_loop. |
can you show you test code? and kazoo version in your project |
@luofeilong version is kazoo (2.2.1) `# -- coding: utf-8 -- import sys logging.basicConfig(level=logging.NOTSET) def is_running(process): class RedisNotUpException(Exception): zk = None from kazoo.exceptions import NodeExistsError class NotConnectToZkServers(Exception): def my_listener(state):
def signal_handler(signal, frame): signal.signal(signal.SIGINT, signal_handler) if name == 'main':
` |
ok, i found the problem in connection.py file
your listener func is waitting for working thread to deal your request; |
yes, you're right. So, if i want to do the operation as my listener function shows, how can i do that? |
maybe you can use another thread to deal event |
so it's the drawback of this library, i think it should be improved. |
yes,you can do it |
I implements my listener as follows:
def my_listener(state):
global zk
global child_path
global child_value
But when command is executed till calling function 'exists', the client gets stuck.
I add logs to track what happened, then I found that because in _connect function the command 'client._session_callback(KeeperState.CONNECTED)' doesn't return.
Next, I found the issue in "remove = listener(state)" in client.py.
In document, it said "creating ephemeral nodes, its highly recommended to add a state listener so that your program can properly deal with connection interruptions or a Zookeeper session loss."
Then, how can I do when connection comes back?
The text was updated successfully, but these errors were encountered: