Metadata-Version: 2.5
Name: render-lab-tasks-core
Version: 0.1.1
Summary: Registration-free HTTP and polling helpers for Render task packs
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: httpx<0.29,>=0.28
Description-Content-Type: text/markdown

# render-lab-tasks-core

Shared mechanisms for Python 3.12+. Version 0.1.1 extends the original 0.1.0 HTTP/polling subset.

```sh
pip install render-lab-tasks-core==0.1.1
```

Registration-free shared HTTP and polling mechanisms. The HTTP/polling surface exposes
`HttpClient`, `ApiError`, and `is_retryable` from `.http`, plus `poll_until` and
`poll_gate` from `.poll`. No tasks, credentials, or vendor-specific DTOs.

Clients use a caller-owned async HTTPX client. Authentication and base URLs resolve
at call time, per-call headers override defaults, empty/malformed JSON maps to None
like the TS reference, and every request makes one attempt by default. Polling checks once and
throws so the durable task policy schedules the next attempt; it never sleeps.

Version 0.1.1 additionally provides UTF-8 byte budgets from
`.bounded` and lazy Google access-token refresh from `.google_auth`. The OAuth
helper accepts either `GOOGLE_ACCESS_TOKEN` or `GOOGLE_CLIENT_ID`,
`GOOGLE_CLIENT_SECRET`, and `GOOGLE_REFRESH_TOKEN`; it shares concurrent refreshes
and caches tokens for the caller-owned client's lifetime with a 60-second margin.
Default task dependencies live for one operation, so reuse an injected client
when cross-call caching is useful. Failed OAuth responses never echo their body. `.http.loads_json` rejects
non-finite numbers so Python-specific NaN/Infinity values cannot escape a DTO.

`.poll.await_retry(every_ms=..., for_ms=...)` returns SDK Retry keyword arguments:
`Retry(**await_retry(every_ms=3000, for_ms=10000))`. The SDK import belongs to the
caller; core has no Render dependency.

`.http.HttpRetryOptions` enables bounded retries only when explicitly passed as
`HttpClient(..., retry=options)`. It retries 429/5xx responses, honors Retry-After,
and otherwise uses capped exponential full jitter. Transport errors propagate.
Sleep and randomness are injectable. All pack defaults remain single-attempt.
`.signatures` provides pure byte comparisons, HMAC encoding, header parsing,
and timestamp-window mechanisms for vendor-owned webhook adapters.

`.http.throw_if_not_ok(response, label)` preserves HTTP status even when reading
the error body fails. Cancellation is never swallowed.
