Skip to main content
tif1.browser holds the parts of tif1 that exist for Pyodide only. They are the HTTP transport that fetches through the browser, and two coroutines that keep the SQLite cache in IndexedDB. The module imports on each platform. Its functions touch the Pyodide runtime only when they run.
Refer to Pyodide and the Browser for the usage guide.

PyodideTransport

The production transport inside Pyodide. PayloadLoader and the shared URL loader select it when sys.platform == "emscripten"; tif1.async_fetch runs its per-URL fetch through get_bytes_async() there, so the bulk loads need no thread pool. Exception contract (the same as every HttpTransport): timeout defaults to the timeout configuration value. Retries belong to the pipeline (retry_with_backoff and the async retry loop), so the pool manager runs with retries=False. The browser owns redirects, compression, and TLS. Example:
Pyodide

get_pyodide_transport()

The shared transport of the runtime (one pool manager per page). tif1.payload_loader.default_transport() returns it inside Pyodide.

enable_persistent_cache()

Mount the cache directory on IndexedDB and load its stored contents. Call it once, before the first get_session(). An open SQLite cache is closed first, and the next get_cache() reopens it on the mounted directory. The mount keeps living in memory; persist_cache() copies the changes to IndexedDB. Parameters:
  • cache_dir: Directory to mount. Defaults to the configured cache_dir.
Returns:
  • The mounted cache directory.
Raises:
  • TIF1Error: Outside Pyodide, or when IndexedDB refuses the sync.

persist_cache()

Write the cache directory to IndexedDB. Pending SQLite writes are committed first (Cache.flush()). Browsers never run atexit hooks, so call it after the loads that must survive a reload. Raises:
  • TIF1Error: Outside Pyodide, or when IndexedDB refuses the sync.
Example:
Pyodide

Runtime Detection

tif1.core_utils.runtime holds the facts the rest of the library consults: The synchronous entry points of Session run their coroutine through one bridge. Natively it is asyncio.run(); in the browser it is pyodide.ffi.run_sync() under JSPI, and AsyncRequiredError without it.

Pyodide and the Browser

Installation, load_async(), JSPI, and cache persistence.

Payload Loader

The HttpTransport seam and the payload pipeline.

Async Fetch

The concurrent fetch pipeline that load_async() drives.

Exceptions

AsyncRequiredError and the transport exception contract.
Last modified on October 28, 2026