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

Utilise uvloop automatically for CLI if present #971

Merged
merged 2 commits into from
Nov 1, 2022
Merged

Conversation

nolar
Copy link
Owner

@nolar nolar commented Nov 1, 2022

uvloop is a drop-in replacement for asyncio's event loops, which promises 2x–2.5x faster execution of the same i/o code (http://magic.io/blog/uvloop-blazing-fast-python-networking/). There is no reason to ignore it if it is installed. For convenience, Kopf can be installed as pip install kopf[uvloop] to bring the mode as a dependency.

This only affects the CLI mode (kopf run …). For in-code execution —e.g. with kopf.run() or kopf.operator()— create or install the event loops explicitly.

Supersedes #719.

@nolar nolar added the enhancement New feature or request label Nov 1, 2022
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
@nolar nolar changed the title Utilise uvloop automatically if present for CLI & synchronous run() Utilise uvloop automatically for CLI if present Nov 1, 2022
`uvloop` is a drop-in replacement for asyncio's event loops, which promises 2x–2.5x faster execution of the same i/o code (http://magic.io/blog/uvloop-blazing-fast-python-networking/). There is no reason to ignore it if it is installed. For convenience, Kopf can be installed as `pip install kopf[uvloop]` to bring the mode as a dependency.

The implicit activation only affects the CLI mode — i.e. `kopf run …`. To disable, uninstall `uvloop`.

For in-code invocations —such as `kopf.run()` or `KopfRunner`— it will use the preinstalled event loop policy (or the default one). `uvloop` is not activated implicitly if Kopf is embedded into a custom application.

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
@nolar nolar merged commit 7d7a83b into main Nov 1, 2022
@nolar nolar deleted the uvloop-if-present branch November 1, 2022 19:39
@nolar nolar mentioned this pull request Nov 1, 2022
5 tasks
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

Successfully merging this pull request may close these issues.

1 participant