Skip to content
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

Add RetryingContext class (B) #60

Closed
wants to merge 2 commits into from
Closed

Add RetryingContext class (B) #60

wants to merge 2 commits into from

Conversation

heri16
Copy link

@heri16 heri16 commented Apr 22, 2017

Alternative implementation with support for AsyncRetrying.

See Issue #48

Example:

with RetryingContext(open) as open:
  with open('filename.txt', 'r') as file:
    ...

with RetryingContext(asyncio.coroutine(open)) as open:
  with (yield from open('filename.txt', 'r')) as file:
     ...

Flow: ContextManager(func) -> retriable_func(func_args) -> func_result -> ContextManager -> file
Async Flow: ContextManager(async_func) -> async_retriable_func(func_args) -> func_result -> ContextManager -> file

Outputs a context manager that returns retriable_func or async_retriable_func on __enter__.
Awaiting of func_result from the async_retriable_func is managed externally by the user.

Alternative implementation.

See Issue jd#48

Example:
```python
with RetryingContext(open) as open:
  with open('filename.txt', 'r') as file:
    ...
```
@heri16 heri16 changed the title Add RetryingContext class Add RetryingContext class (B) Apr 22, 2017
@jd
Copy link
Owner

jd commented Apr 24, 2017

The with statement adds nothing again here. It's just equivalent to f = retry(someargs)(f).

@jd jd closed this Apr 24, 2017
@heri16 heri16 deleted the patch-2 branch April 25, 2017 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants