Comments (5)
I don't think we should capture ctrl+c in this lib and cancel the watch.
As we had expose the cancel method to user, they should do it in their code.
from python-etcd3.
So it kinda works in python 3, but looking at grpc/grpc#6999, it seems upstream grpc people don't care. Maybe leaving this and documenting that it doesn't work in python 2 would be best.
from python-etcd3.
Oh, didn't know it's because of condition.wait()... I'm not a python expert, do we have something better to replace condition.wait()?
BTW, in one of my project, I start a daemon thread to watch the key change, But when the main thread exit, it print an error message said "segmentation fault". Not sure if related to the usage of condition.wait(), as the doc said daemon thread will exit if it's the only thread...
from python-etcd3.
This may be related, but it seems a bit more problematic. Thought about opening it as a separate issue, but I figured I would give it a try here instead.
I am running etcd3-0.9.0-py3.7 under python 3.7.1 on MacOS 10.13.6 (High Sierra).
As a demonstration, I have the following simple script:
import threading
import etcd3
etcd = etcd3.client()
result = etcd.watch_prefix_once("/")
print(str(result))
for t in threading.enumerate():
print(str(t))
exit(0)
When I run this and then, in another window add a key "/foo" with a value of "value for /foo", what I see is:
$ python3 foo.py
<class 'etcd3.events.PutEvent'> key=b'/foo' value=b'value for foo'
<_MainThread(MainThread, started 140735995216768)>
<Thread(etcd3_watch_10b4cd748, started daemon 123145335029760)>
<Thread(Thread-1, started daemon 123145340284928)>
<Thread(Thread-2, started daemon 123145345540096)>
as expected, followed by a hang in exit that can only be cleared by a ^C.
This also happens if I am watching indefinitely, exit the watching loop and call cancel(), but the above is a simpler example. As you can see, the watch callback thread is still running after the completion of the watch_prefix_once() which may or may not be expected. That said, it is daemonized, so it should terminate when exit() is called.
I also tried adding a timeout to the watch_prefix_once() call, but that does not resolve the problem. The script still hangs indefinitely on exit, whether the timeout is hit during the call and exceptions out of the script or the call receives an event before the timeout is hit.
So far I have not been able to come up with a workaround for this. It appears that calling any flavor of watch permanently contaminates the process and it will not properly exit after that.
from python-etcd3.
It looks like my problem (described above) is a regression in 0.9.0-py3.7 because I don't see it when I install 0.8.1.
Also, another datapoint (related? not sure) I tried adding a call to etcd.close() (i.e. client.close()) before the exit in the example I showed, thinking this might be a workaround. When I do that, the watcher thread exceptions with a ValueError from grpc saying the channel is closed and then python locks up until I hit ^C. After the ^C, though, I am able to exit without hanging. Again, this is only in 0.9.0 as far as I can tell.
from python-etcd3.
Related Issues (20)
- get key detail from callback function
- a problem in using lease HOT 1
- client.close() occasionally takes 10s
- python-etcd3 is incompatible with grpcio versions newer than 1.44.0 (1.45+) HOT 5
- etcd3 does not connect to 3.5.0 server but etcd does HOT 1
- Do you still maintain this project? HOT 10
- TypeError: Descriptors cannot not be created directly HOT 1
- hi guy,we need to come up with a new version to fix the previous problem. If there is, I can help.
- Can't use etcd3 package? HOT 6
- locking with python3-etcd3 0.12.0 on etcd 3.4.23 fails? HOT 3
- Release plan after 0.12.0 HOT 1
- Bug in grpcio>=1.54.0 HOT 1
- Installing etcd3 HOT 2
- Let `python-etcd3` renew auth token when expired between calling `Lock.acquire` and `Lock.release`
- Updated release HOT 2
- How can I skip tls verify when I use the cert file?
- etcd3-client throwing error -
- about add_watch_callback HOT 1
- Can you help me upgrade the version number?
- How to "keep-alive" by lease_id? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-etcd3.