-
Notifications
You must be signed in to change notification settings - Fork 26
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
self cancelling watcher #110
Comments
Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details. |
you can use |
I knew that! Thanks Revolution1. |
Actually I played with watch_once() and it blocks the main thread (fine) but doesn't release after the callback executes. Maybe I'm using it wrong:
During execution I'll see:
And it won't continue. Any suggestions? Thanks. |
Ah got it. I have to return the event in my once run callback:
|
uh... no So you are using the filter as a callback. the correct way to use is: w = Watcher(...)
e = w.watch_once() # default None accept all kinds of event
# or
e = w.watch_once('.*123') # regex filter the event of which key ends with '123' The you can use the returned Event |
Ok, that makes sense. I was confused by the onEvent() taking a filter_or_cb and also cb, and that the constructor for Watcher includes the key'ing, but of course I can further filter for something like EventType. Great, I can remove the callback, which was a pain to debug as it runs in another thread. Anyways, thanks for the follow up! |
The purpose of In these use case:
thus, only one watcher is created, only one stream open In conclusion, the first argument or |
Description
Maybe this is a Python thing I can work out, but I'm trying to have a watcher that'll self cancel within an event callback. Like watch once, or watch until some condition is satisfied, then cancel itself.
I've designed a kind of request/approval protocol on top of etcd and I'd like the watch to end when my approval watch fires. Any suggestions?
Excellent, stable library BTW. Thanks!
What I Did
The text was updated successfully, but these errors were encountered: