Skip to content

perf: 修复httpx.AsyncClient 每次构造时会同步创建 SSLContext #160

@Aliothmoon

Description

@Aliothmoon
_client = httpx.AsyncClient()

async def get_from_pypi(url: str) -> Optional[str]:  # -> '1.8.0b1'
    try:
        req = await _client.get(url, timeout=5)
        if req.status_code == 200:
            return req.json().get("info", {}).get("version", None)
        else:
            return None
    except Exception as e:
        print(f"WARNING: Failed to check update from {url}", e)
        return None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions