Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

AWS Lambda & API Gateway support for ASGI

Project description


Package version Build Status

Mangum is an adapter for using ASGI applications with AWS Lambda & API Gateway.



Python 3.7


pip3 install mangum


The adapter class Mangum accepts the following optional arguments:

  • debug : bool (default=False)

    Enable a simple error response if an unhandled exception is raised in the adapter.

  • enable_lifespan : bool (default=True)

    Specify whether or not to enable lifespan support.


from mangum import Mangum

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

handler = Mangum(app, enable_lifespan=False) # disable lifespan for raw ASGI example

WebSockets (experimental)

The adapter currently provides some basic WebSocket support using boto3 with DynamoDB. To install Mangum with the optional dependency:

pip3 install mangum[full]


Any ASGI framework should work with Mangum, however there are cases where certain non-ASGI behaviour of an application will cause issues when deploying to a serverless platform.

Project details

Download files

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

Files for mangum, version 0.6.17
Filename, size File type Python version Upload date Hashes
Filename, size mangum-0.6.17.tar.gz (7.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page