Spaces:
Running
Running
sync: upstream 9194f15 + custom addons (KeyRotator, RotatingChatTransport, sol/terra/luna, ScannerTrap, health, Py3.12 compat)
e99df76 Download src/free_claude_code/runtime/lifecycle.py from dherain24/claude-proxy: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/src/free_claude_code/runtime/lifecycle.py
- Command line
-
hf download hf://spaces/dherain24/claude-proxy/src/free_claude_code/runtime/lifecycle.py
-
curl -L -o lifecycle.py https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/src/free_claude_code/runtime/lifecycle.py
1.11 kB
| from __future__ import annotations | |
| """Shared cleanup reporting for runtime resource owners.""" | |
| from collections.abc import Awaitable | |
| from loguru import logger | |
| async def best_effort( | |
| name: str, | |
| awaitable: Awaitable[object], | |
| *, | |
| log_verbose_errors: bool = False, | |
| ) -> bool: | |
| """Run one cleanup step and report whether it completed. | |
| The lifecycle owner intentionally applies no generic timeout here. Cancelling | |
| an arbitrary cleanup at a deadline can abandon a half-closed SDK, thread, or | |
| provider resource; resource-specific cleanup or the process supervisor owns | |
| any force-termination deadline. | |
| """ | |
| try: | |
| await awaitable | |
| except Exception as exc: | |
| if log_verbose_errors: | |
| logger.warning( | |
| "Shutdown step failed: {}: {}: {}", | |
| name, | |
| type(exc).__name__, | |
| exc, | |
| ) | |
| else: | |
| logger.warning( | |
| "Shutdown step failed: {}: exc_type={}", | |
| name, | |
| type(exc).__name__, | |
| ) | |
| return False | |
| return True | |