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 AsyncRetryingContext class (A) #61

Closed
wants to merge 1 commit into from
Closed

Conversation

heri16
Copy link

@heri16 heri16 commented Apr 22, 2017

This implementation uses a single shared async context manager.
See Issue #48

Example:

async with AsyncRetryingContext(open, wait=wait_fixed(2))('filename.txt', 'r') as file:
  ...

Flow: AsyncContextManager(func, retry_opts)(func_args) -> async_retriable_func(func_args) -> [func_result] -> file

Outputs an async context manager that generates async_retriable_func on __aenter__. It then internally passes in func_args into this async_retriable_func and awaits for the func_result.

  • If the func_result is a value, this value is returned by by __aenter__ to be passed into the new context as file.
  • If the func_result is another context manager, it also calls __enter__ on this wrapped context manager. If __enter__ returns a truthy value, this value is in turn returned by __aenter__ to be passed into the new context as file.

See Issue jd#48

Example:
```python
async with AsyncRetryingContext(open)('filename.txt', 'r') as file:
  ...
```
@heri16 heri16 changed the title Add AsyncRetryingContext class Add AsyncRetryingContext class (A) Apr 22, 2017
@heri16
Copy link
Author

heri16 commented Apr 23, 2017

Ok, this implementation has no merit. Closing.

@heri16 heri16 closed this Apr 23, 2017
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.

1 participant