MCPcopy
hub / github.com/psf/black / maybe_use_uvloop

Function maybe_use_uvloop

src/black/concurrency.py:30–47  ·  view source on GitHub ↗

If our environment has uvloop or winloop installed we use it otherwise a normal asyncio eventloop is called as fallback. This is called only from command-line entry points to avoid interfering with the parent process if Black is used as a library.

()

Source from the content-addressed store, hash-verified

28
29
30def maybe_use_uvloop() -> asyncio.AbstractEventLoop:
31 """If our environment has uvloop or winloop installed we use it otherwise
32 a normal asyncio eventloop is called as fallback.
33
34 This is called only from command-line entry points to avoid
35 interfering with the parent process if Black is used as a library.
36 """
37 try:
38 if sys.platform != "win32":
39 import uvloop
40
41 return uvloop.new_event_loop()
42 else:
43 import winloop
44
45 return winloop.new_event_loop()
46 except ImportError:
47 return asyncio.new_event_loop()
48
49
50def cancel(tasks: Iterable[asyncio.Future[Any]]) -> None:

Callers 2

mainFunction · 0.90
reformat_manyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected