Skip to main content

Daemon-less commander/worker model serving GenroPy legacy sites on top of genro-asgi

Project description

genropy-asgi

Serve legacy (synchronous) GenroPy sites on an ASGI server — no register daemon. genropy-asgi is the GenroPy-specific bridge on top of genro-asgi: it hosts an unmodified GnrWsgiSite behind uvicorn and, on demand, spreads the load over a supervised pool of worker processes.

What it replaces

  • gnrwsgiserve (werkzeug/WSGI) → gnrasgiserve (uvicorn/ASGI). Same site, same options, unmodified code — plus native WebSocket support.
  • The register daemon (Pyro4, then genro-nodaemon) → an in-process register. There is no daemon to start or connect to.

Installation

pip install genropy-asgi

Latest development version, straight from GitHub:

pip install git+https://github.com/genropy/genropy-asgi.git

genro-asgi is installed automatically. GenroPy must be present at runtime (the worker runs a GnrWsgiSite) and configured as usual (~/.gnr/environment.xml plus an existing site). genropy-asgi imports gnr.* only at runtime.

Usage

Single process — the drop-in for gnrwsgiserve:

gnrasgiserve mysite -p 8080
# site on http://0.0.0.0:8080/index

Pool — one commander supervising N workers, sticky per user:

gnrasgiserve mysite --workers 2 -p 8080

mysite is the GenroPy instance name (or a site path). With --workers N the same command runs the commander/worker model: each user is routed to a stable worker and the pool grows under load.

Watch the pool:

curl -s http://127.0.0.1:8080/_server/monitor_state | python3 -m json.tool

How it works

A GenroPy site is synchronous WSGI. genropy-asgi converts each ASGI request to a PEP 3333 environ and runs the site in a thread executor, so uvicorn is never blocked. The site's register — connections, pages, sessions, datachanges, stores — is served in-process, not by a daemon.

  • Single (GenropySpaApplication): one process hosts the site and is the commander of itself.
  • Pool: a commander (GenropyCommanderApplication, the genro-asgi core commander plus the site-wide /metrics endpoint) supervises N workers (GenropyWorkerApplication), forwards every request to the right worker by an opaque sticky_cid cookie, and grows the pool when every worker crosses 80% of its user cap. Datachanges live locally on the page's own worker (the switch model); cross-worker changes arrive via the commander. The legacy globalStore() is eventually coherent via the framework's global-store rail — a write on one worker reaches the others after one channel round-trip.

The commander serves a Prometheus /metrics endpoint exposing the pool's site-wide counters (users, pages, connections). Watch the pool with:

curl -s http://127.0.0.1:8080/metrics

See docs/ for the full architecture, single-vs-multi guide, configuration, CLI reference, FAQ and troubleshooting.

Documentation

The documentation is built with Sphinx:

pip install -e .[docs]
cd docs && make html
# open docs/_build/html/index.html

Development

pip install -e .[dev]
pytest tests/
ruff check src/

License

Apache License 2.0 — Copyright 2025 Softwell S.r.l. See LICENSE and NOTICE.

Project details


Download files

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

Source Distribution

genropy_asgi-0.2.0.tar.gz (101.8 kB view details)

Uploaded Source

Built Distribution

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

genropy_asgi-0.2.0-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file genropy_asgi-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for genropy_asgi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5f6dc164714daadd1586aae15c24077c86547d43d6a40790ff17e9a081a673b9
MD5 ad98af6f286c9239e290c1305defb2b8
BLAKE2b-256 83ec1ccb9ea201e7a46dfd2efa14e635144e3fd522ca76b8bf0abff6399ffaa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for genropy_asgi-0.2.0.tar.gz:

Publisher: publish.yml on genropy/genropy-asgi

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

File details

Details for the file genropy_asgi-0.2.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for genropy_asgi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26578805773659c270db22b53a3f00b9efa4fc10cddea1412da0bda86899d3de
MD5 c9dc4d254a0b3676c1f1f66c8839eb1d
BLAKE2b-256 3168a85cd8dae7b5cd980b2afebb772699f1654a0747075e07b0842e38608c6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for genropy_asgi-0.2.0-py3-none-any.whl:

Publisher: publish.yml on genropy/genropy-asgi

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 Pingdom Monitoring Sentry Error logging StatusPage Status page