Try another way to run Python.

Explore synchronous endpoints and parallel work.

If you want to experiment with ordinary def handlers and free-threaded Python, Karak includes a separate HTTP implementation you can run locally. Use it to explore how your own workload behaves with several worker threads.

It is research software with a different API from the main framework. For your first Karak application, start with the quickstart.

Run the sample application

From your Karak checkout:

uv sync --group experiments --python 3.13t
uv run --group experiments --python 3.13t python -m experiments.free_threaded.examples.basic

Here 3.13t selects a free-threaded Python build. Visit localhost:8000 to see the sample application.

Try your own endpoint

Save this as threaded_example.py in the repository root:

from experiments.free_threaded import Karak

app = Karak()


@app.get("/")
def index():
    return {"message": "Hello from Karak"}


if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8000, workers=4)

Stop the sample server with Ctrl+C first, then run:

uv run --group experiments --python 3.13t python threaded_example.py

The endpoint returns JSON. You can also explore typed request bodies and shared dependencies using the included example. Those features belong to this experiment, not the main ASGI API.

Compare a workload

Stop any servers on ports 8001 and 8002 before running the comparison:

uv run --group experiments --python 3.13t python -m experiments.free_threaded.benchmarks.run_benchmark 1000 10

This sends 1,000 requests with 10 concurrent clients for each workload. It compares the threaded experiment with a FastAPI example. The results depend on your machine, Python build, and workload; they do not measure the main Karak framework.

The experiment guide has more details and historical results.

What this experiment is for

It helps investigate the planned execution experience: ordinary Python that can take advantage of the machine it runs on. It is not a production deployment option or a background-job system. Use it from the repository; it is not included in the installed karak package.

Type to find a page.