-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
Provide a generator decorator #58
Comments
How would you use it? |
|
I don't see how the result is useful here? If you expect |
@jd sorry for the lack of context, I think I abstracted the example too much :) In my particular usage See below:
|
Iterators are particular, if you're ready to restart it as soon as it fails, it means you basically want it entirely. So you actually want import tenacity
s = {'calls': 0}
def gen():
s['calls'] += 1
yield 1
yield 2
if s['calls'] == 1:
raise Exception
yield 3
r = tenacity.Retrying()
ret = r(lambda: list(gen()))
print(ret) # prints [1, 2, 3] So I'm not sure it needs anything else here? |
Maybe that's too specific to how gRPC (ab)use of generator for streaming, but the semantic is the following:
The This makes it challenging for me to use This could work if we wrap the whole logic consuming the generator with
But I was hoping I could insert
Let me know if that makes sense :) |
Maybe the best solution would be a context manager such as suggested in #48 |
@jd You're right! I definitely agree that would provide a nice solution to this problem! Feel free to close this issue ;) |
Would it make sense to have a
@retry
variant that better support generator functions?Something like:
The text was updated successfully, but these errors were encountered: