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

Unify the publicly exported sync/async daemon-stopping flag #757

Merged
merged 2 commits into from
May 10, 2021

Conversation

nolar
Copy link
Owner

@nolar nolar commented May 10, 2021

Previously, Union of sync & async checkers was used in the daemon protocol. As a result, it forced the operator developers to accept both types and do proper handling of both cases — when in fact only one checker was passed according to the daemon type (sync/async).

To simplify type-checking of operators, both sync & async checkers are now downgraded to implementation details (but remain exported for backwards compatibility), while only the base class is exposed for type annotations of the stopped kwarg. To achieve this, some "clean" (as in, "not dirty") trickery was implemented — see the docstring of the new “promise” class.

All public interfaces should remain supported without breaking them. Even evaluating the results of stopped.wait() as booleans remain there: the returned value is the flag/checker itself, but it is bool-evaluable (unless x is True/x is False conditions were used).

Related #747. Fixes #746. Replaces #748.

nolar added 2 commits May 10, 2021 18:14
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Previously, `Union` of sync & async checkers was used in the daemon protocol. As a result, it forced the operator developers to accept both types and do proper handling of both cases — when in fact only one checker was passed according to the daemon type (sync/async).

To simplify type-checking of operators, both sync & async checkers are now downgraded to _implementation details_ (but remain exported for backwards compatibility), while only the base class is exposed for type annotations of the `stopped` kwarg. To achieve this, some "clean" (as in, "not dirty") trickery was implemented — see the docstring of the new “promise” class.

All public interfaces should remain supported without breaking them. Even evaluating the results of `stopped.wait()` as booleans remain there: the returned value is the flag/checker itself, but it is bool-evaluable (unless `x is True`/`x is False` conditions were used).

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring Code cleanup without new features added
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant