| 18 | |
| 19 | |
| 20 | def run(args: Sequence[str] | None = None) -> None: |
| 21 | try: |
| 22 | with ToxHandler.patch_thread(): |
| 23 | result = main(sys.argv[1:] if args is None else args) |
| 24 | except Exception as exception: |
| 25 | if isinstance(exception, HandledError): |
| 26 | logging.error("%s| %s", type(exception).__name__, exception) # noqa: TRY400 |
| 27 | result = -2 |
| 28 | else: |
| 29 | raise |
| 30 | except KeyboardInterrupt: |
| 31 | result = -2 |
| 32 | finally: |
| 33 | if "_TOX_SHOW_THREAD" in os.environ: # pragma: no cover |
| 34 | import threading # pragma: no cover # noqa: PLC0415 |
| 35 | |
| 36 | for thread in threading.enumerate(): # pragma: no cover |
| 37 | print(thread) # pragma: no cover # noqa: T201 |
| 38 | raise SystemExit(result) |
| 39 | |
| 40 | |
| 41 | def main(args: Sequence[str]) -> int: |