X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/f2ea461e9e9fa5c47bb61fd72d512c748928badc..1af533108968e40cc005079a328ad117a864af13:/src/black/concurrency.py?ds=inline diff --git a/src/black/concurrency.py b/src/black/concurrency.py index 119a9a7..69d79f5 100644 --- a/src/black/concurrency.py +++ b/src/black/concurrency.py @@ -6,6 +6,21 @@ from typing import Any, Iterable from black.output import err +def maybe_install_uvloop() -> None: + """If our environment has uvloop installed we use it. + + This is called only from command-line entry points to avoid + interfering with the parent process if Black is used as a library. + + """ + try: + import uvloop + + uvloop.install() + except ImportError: + pass + + def cancel(tasks: Iterable["asyncio.Task[Any]"]) -> None: """asyncio signal handler that cancels all `tasks` and reports to stderr.""" err("Aborted!")