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.
()
| 28 | |
| 29 | |
| 30 | def 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 | |
| 50 | def cancel(tasks: Iterable[asyncio.Future[Any]]) -> None: |
no outgoing calls
no test coverage detected