Skip to main content

fluxwright

Run hundreds of headless Chrome jobs on one machine, with a Playwright-style API. Each new_page is a fresh browser context on a pooled Chrome. The engine queues jobs when every slot is busy, restarts browsers before they bloat, and replaces browsers that crash.

Docs: https://fluxwright.vercel.app

Requires a local Chrome/Chromium binary (FLUXWRIGHT_CHROMIUM, CHROME, CHROMIUM, or a standard install path). For headless jobs, chrome-headless-shell is picked up from PATH or Puppeteer's/Playwright's cache and opens pages much faster: npx @puppeteer/browsers install chrome-headless-shell@stable.

Install

pip install fluxwright

Wheels cover Windows x64, macOS (Intel and Apple Silicon) and Linux x86_64, for Python 3.10 and newer. Anywhere else, pip builds from source, which needs Rust.

Use

asyncio:

import asyncio
from fluxwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch(max_browsers=4)
        page = await browser.new_page()
        await page.goto("https://example.com")
        print(await page.get_by_role("heading").text_content())  # "Example Domain"
        print(await page.evaluate("() => location.hostname"))
        png = await page.screenshot(full_page=True)  # bytes
        await page.close()
        await browser.close()

asyncio.run(main())

Blocking code:

from fluxwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com")
    print(page.title())
    browser.close()

The names are Playwright's, so a Playwright script for the features below runs after changing playwright.async_api to fluxwright.async_api (or sync_api). chromium can also be imported directly: from fluxwright.async_api import chromium.

Many jobs at once: start them all and let the engine queue them.

async def job(browser, url):
    page = await browser.new_page()
    try:
        await page.goto(url)
        return await page.title()
    finally:
        await page.close()

titles = await asyncio.gather(*(job(browser, url) for url in urls))

The sync API runs every call on one event loop in a background thread, so its objects work from any thread: a ThreadPoolExecutor of jobs sharing one browser is fine (Playwright's sync API does not allow that).

API

Method What it does
chromium.launch(max_browsers=None, executable_path=None, headless=None, queue_timeout=None) Start the pool (4 browsers by default). Headless uses chrome-headless-shell when installed (as Playwright does), else Chrome; FLUXWRIGHT_CHROMIUM or executable_path overrides. When every slot is busy, new_page waits its turn however long the queue is, so starting every job at once works; with queue_timeout (ms) it raises TimeoutError after that long instead, counting a browser start when one is needed
browser.new_page(...) A fresh browser context. Every option applies to this page only: proxy={"server", "bypass", "username", "password"}, user_agent, locale, timezone_id, geolocation={"latitude", "longitude", "accuracy"} (with permissions=["geolocation"]), permissions, viewport={"width", "height"}, device_scale_factor, color_scheme, storage_state (a dict or a file path)
page.storage_state(path=None) Every cookie in the context plus localStorage of the current origin, in Playwright's format. With path, also saved as JSON for new_page(storage_state=path)
page.goto(url, wait_until=None) Navigate. wait_until: load (default), domcontentloaded, networkidle, commit
page.title() / page.content() Read
page.click(selector) / page.fill(selector, value) Scrolls into view, waits until enabled, stable, and not covered. Selector: CSS, text=Foo, text="Exact", role=button[name="Save"]
page.get_by_role(role, name=None, exact=None) / get_by_text(text, exact=None) / get_by_label / get_by_placeholder / get_by_test_id(id) / page.locator(selector) A Locator with click(), fill(v), wait_for(), text_content(), bounding_box(), screenshot(path=None) and evaluate("(el, arg) => ...", arg)
locator.nth(i) / .first / .last / filter(has_text=...) / locator.get_by_role(...) and the other finders Narrow a locator: by position (negative counts from the end), by contained text (case-insensitive), or by searching inside its matches
page.frame_locator(iframe_selector) The same finders inside an iframe, same- or cross-origin; nest with .frame_locator()
page.evaluate(expression, arg=None) Runs JavaScript in the page and returns its JSON result, awaiting promises. A function ("(x) => x * 2") is called with arg; anything else is evaluated as is. A thrown error raises fluxwright.Error
page.screenshot(full_page=None, path=None) PNG bytes, also written to path
page.route(url, handler) / page.unroute(url, handler=None) Request interception: url is a glob (**/api/*), a compiled regex or a function of the URL; the handler gets route (and request, if it takes two arguments) and answers with route.fulfill(status, headers, body, json, path, content_type), route.continue_(url, method, headers, post_data), route.abort(error_code) or route.fallback(). The handler added last runs first
page.on("console" | "pageerror", handler) / once / remove_listener Console messages (.type, .text) and uncaught errors (fluxwright.Error with .name, .message, .stack) as they happen
page.expect_download(timeout=None) / page.wait_for_download(timeout=None) The next download the page finished: .url, .suggested_filename, path(), save_as(path). Files are deleted when the page closes
page.console_messages() / page.page_errors() What the page, its popups and iframes logged, and the exceptions nothing caught, the last 1000 of each. Fail a job with assert await page.page_errors() == []
page.set_viewport_size({"width", "height"}) CSS-pixel viewport for this page
page.wait_for_selector(selector) Waits until visible (Playwright's default state)
page.close() / browser.close() Dispose the context / shut down

Timeouts are in milliseconds, as in Playwright. Errors are fluxwright.Error, and fluxwright.TimeoutError when something ran out of time. Close pages when a job is done; a page you forget is cleaned up when Python collects it.

In the sync API, route handlers run on worker threads and event listeners one at a time on a thread of their own, so both can call the page.

Develop

pip install maturin pytest
maturin develop   # needs Rust
pytest            # against a real Chrome

License

Licensed under the Apache License, Version 2.0.

Metadata

Release files for fluxwright 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fluxwright 0.4.1
File Size Uploaded Provenance Actions
fluxwright-0.4.1.tar.gz 113.1 kB Without provenance Details for fluxwright-0.4.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fluxwright 0.4.1
File Actions
fluxwright-0.4.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for fluxwright-0.4.1-cp310-abi3-win_amd64.whl
fluxwright-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for fluxwright-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
fluxwright-0.4.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for fluxwright-0.4.1-cp310-abi3-macosx_11_0_arm64.whl
fluxwright-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for fluxwright-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 7.3 MB

Release files / fluxwright-0.4.1.tar.gz

Download URL fluxwright-0.4.1.tar.gz
Size 113.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6972b103f0a7aa9eb005c728a4ab9cfda0433cbe85cdda1ed030a5a6fb227201
BLAKE2b-256 checksum
How to use checksums
1d97d2368f42bd7c07a1f31669f7bfda38ba0d776f536859002722ac14208844
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Release files / fluxwright-0.4.1-cp310-abi3-win_amd64.whl

Download URL fluxwright-0.4.1-cp310-abi3-win_amd64.whl
Size 1.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d24db36c9920546d7eb9b435b7b227190775551979e4f12bb88d6407b3832877
BLAKE2b-256 checksum
How to use checksums
9c5fcc762cc4d7f2690c138d59ce4fa490aea78de50b69dd1c5423967f3c5689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Release files / fluxwright-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fluxwright-0.4.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
49e871f54b1120faa218c3897ab821f12e23fd50bd8a8502d2b4f8c9a07138f9
BLAKE2b-256 checksum
How to use checksums
3a6b58a3c0061b60d1366e39b265a8c6806da57b219be4f2badf8ddd7d04a71b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Release files / fluxwright-0.4.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL fluxwright-0.4.1-cp310-abi3-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
70d80d5cc87c710e3f92c0becf33af4c02d415f106ad36ecfa467f638f8c9d83
BLAKE2b-256 checksum
How to use checksums
41b2c34dbdbd298612d6a7f2af0d1be4f451dd5ad638b28a04450234be21229d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Release files / fluxwright-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL fluxwright-0.4.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.7 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bc1d87fd76d5393cf790196c1447d8bb56737940336d9a9368de42c09cf89adf
BLAKE2b-256 checksum
How to use checksums
c6c1cf0ac1c2345d409e016181d843c40a2e523433174679807ba81f66cf347f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Security for fluxwright 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page