Skip to main content

An adapter for asgi to rsgi

Project description

rsgiadapter

PyPI - Version GitHub License PyPI - Downloads PyPI - Status

An Asgi to rsgi adapter.

RSGI Specification ref: https://github.com/emmett-framework/granian/blob/master/docs/spec/RSGI.md

rsgiadapter is an adapter for RSGI server run ASGI application like FastAPI and BlackSheep.

Usage:

app.py

import granian
from granian.constants import Interfaces
from rsgiadapter import ASGIToRSGI

app = None  # Define your asgi application here

rsgi_app = ASGIToRSGI(app)

serve = granian.Granian("app:rsgi_app", interface=Interfaces.RSGI)
serve.serve()

with asgi lifespan:

from contextlib import asynccontextmanager

import granian
from granian.constants import Interfaces
from rsgiadapter import ASGIToRSGI


@asynccontextmanager
async def lifespan(_app):
    print("lifespan start")
    yield
    print("lifespan stop")


app = None  # Define your asgi application here

rsgi_app = ASGIToRSGI(app, lifespan=lifespan)

serve = granian.Granian("app:rsgi_app", interface=Interfaces.RSGI)
serve.serve()

Supported Feature:

  • HTTP Request Response
    • ASGI scope
    • ASGI receive
    • ASGI send
  • Extensions
    • http.response.pathsend
    • websocket.http.response
    • http.response.push
    • http.response.zerocopysend
    • http.response.early_hint
    • http.response.trailers
    • http.response.debug
  • Lifespan
    • lifespan.startup
    • lifespan.startup.complete(silence)
    • lifespan.startup.failed(will terminate)
    • lifespan.shutdown
    • lifespan.shutdown.complete(silence)
    • lifespan.shutdown.failed(will terminate)

Ref:

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

rsgiadapter-0.0.6.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

rsgiadapter-0.0.6-py3-none-any.whl (9.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page