INNER CODE UNIT · Python

_check_tor_connectivity_async

KatrielMoses/voidaccess · api/main.py:537

async def _check_tor_connectivity_async() -> str:
    """Return 'ok' if Tor proxy is reachable, 'unreachable' otherwise."""
    host = os.getenv("TOR_PROXY_HOST", "127.0.0.1")
    port = int(os.getenv("TOR_PROXY_PORT", "9050"))
    try:
        reader, writer = await asyncio.wait_for(
            asyncio.open_connection(host, port), timeout=3.0
        )
        writer.close()
        await writer.wait_closed()
        return "ok"
    except Exception:
        return "unreachable"


def _check_db_connectivity() -> bool:
    """Return True if DB is reachable, False otherwise. Sync wrapper for startup."""
    if not os.getenv("DATABASE_URL"):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…