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

Guaranteed Postponement Context #65

Open
maxfischer2781 opened this issue Oct 25, 2019 · 0 comments
Open

Guaranteed Postponement Context #65

maxfischer2781 opened this issue Oct 25, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@maxfischer2781
Copy link
Contributor

Short description of the feature
Provide a context that postpones exactly once, even when nested. This would allow combining multiple high-level calls as a quasi-atomic async operation.

This is intended as a helper for creating high-level operations. It is required to build new abstractions; users of existing abstractions do not need it.

Describe the solution you'd like
Add an async with context that opens a postponement scope or resumes an outer one. The outermost context will postpone if it is exited at the same time and turn as it was entered. Nested scopes delegate the responsibility to outer scopes.

Postponement is dynamically scoped, meaning that any postponement in an __await__, __aenter__/__aexit__ or __aiter__/__anext__ is considered nested in any outer postponements.

async with postponed():  # open scope
    async with postponed():  # resume scope
        await something()  # resume scope?

Enforcing only postponement, not suspension, is optional.

Describe alternatives and the context you have considered
This has originated from #64. In such a specific case, a special cased implementation could be made. However, these special cases must be carefully constructed to avoid duplicate postponement. Combining several high-level calls is very difficult.

@maxfischer2781 maxfischer2781 added the enhancement New feature or request label Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant