Skip to main content

toncorn

An ASGI web server for free-threaded Python, powered by tonio.

toncorn is a fork of uvicorn that swaps the asyncio runtime for tonio.

Install

$ pip install toncorn

toncorn requires free-threaded CPython 3.14 or newer (python3.14t) and runs PYTHON_GIL=0. Linux and macOS only; Windows is not supported and won't be (tonio doesn't target it).

For the optional protocol/parser extras (matching upstream uvicorn's [standard] set):

$ pip install 'toncorn[standard]'

Quickstart

example.py:

async def app(scope, receive, send):
    assert scope["type"] == "http"
    await send({
        "type": "http.response.start",
        "status": 200,
        "headers": [(b"content-type", b"text/plain")],
    })
    await send({
        "type": "http.response.body",
        "body": b"Hello, world!",
    })

Run it:

$ PYTHON_GIL=0 toncorn example:app

You'll see a banner identifying the toncorn version and the uvicorn version it tracks:

INFO:     toncorn 0.48.0.0 (uvicorn 0.48.0)
INFO:     Started server process [12345]
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

The package ships both import toncorn and import uvicorn — the source tree lives under the original uvicorn package name to keep the diff against upstream small, and toncorn is a thin re-export. Pick whichever import you prefer; they expose the same Config, Server, run, main.

Note: this means toncorn and the real PyPI uvicorn collide on the uvicorn import name; don't install both in the same environment.

Programmatic use

import toncorn
toncorn.run("example:app", host="127.0.0.1", port=8000)

Or with an explicit Config + Server:

import toncorn

config = toncorn.Config(app=app, host="127.0.0.1", port=8000)
server = toncorn.Server(config)
server.run()

Differences from uvicorn

  • Runtime is tonio, not asyncio. There's no --loop flag, no uvloop/asyncio switch. Everything runs on a single tonio runtime with a configurable thread pool.
  • Concurrency model is threads, not processes. The old --workers N flag is replaced by --threads N, which sizes the tonio scheduler's thread pool. No multiprocessing supervisor, no preforked workers, no graceful-restart process orchestration.
  • No --reload. The auto-reload supervisor is gone. Use your editor's hot-reload or a separate process manager during development.
  • No Windows support. POSIX only.
  • No in-tree WSGI middleware. The deprecated WSGI bridge has been removed; use a2wsgi or asgiref.wsgi if you need WSGI compatibility.
  • Python 3.14+ only. Earlier Python versions are not supported.

The version number reflects both upstream and fork: {uvicorn}.{toncorn}, so 0.48.0.0 tracks uvicorn 0.48.0 with toncorn patch 0. Patch-level releases against the same uvicorn baseline bump the last segment (0.48.0.00.48.0.1).

Upstream tracking

The source tree under uvicorn/ is kept as close to upstream uvicorn as possible to make merges/rebases tractable. Fork-specific changes are intentionally minimal and called out where they appear. The toncorn/ package is a re-export shim plus the toncorn-specific version.

License

BSD-3-Clause, same as upstream uvicorn. See LICENSE.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toncorn-0.51.0.0.tar.gz (61.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toncorn-0.51.0.0-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file toncorn-0.51.0.0.tar.gz.

File metadata

  • Download URL: toncorn-0.51.0.0.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for toncorn-0.51.0.0.tar.gz
Algorithm Hash digest
SHA256 abdd205bb8be8d981fd8d5d12b034ed148fc41d3d0a6d1fc57b281083f8ce8fc
MD5 2a3d59d9c7b7fad03ee36afa746e856a
BLAKE2b-256 c76dbb369e75614bea8e2ecc81cf8205cb4eabb1c1a3596fac6d3511043dd09d

See more details on using hashes here.

Provenance

The following attestation bundles were made for toncorn-0.51.0.0.tar.gz:

Publisher: publish.yml on gi0baro/toncorn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file toncorn-0.51.0.0-py3-none-any.whl.

File metadata

  • Download URL: toncorn-0.51.0.0-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for toncorn-0.51.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 195bbfb8cedff7bcf9c20f6e1f4402a399d5191de9c30c512df47f38d5076f43
MD5 10cb93e20d85c30d885d8e63eac336b8
BLAKE2b-256 1f711b320e9c09131627a237bdef8834a64c6933ca0fb900bd01698ef0f4e1c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for toncorn-0.51.0.0-py3-none-any.whl:

Publisher: publish.yml on gi0baro/toncorn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page