Skip to main content

AMQP support for Sanic framework

Project description

AMQP support for Sanic framework


  • Based on the aioamqp library

  • Provides an opportunity to implement workers that works in background


This package should be installed using pip:

pip install sanic-amqp-extension


from sanic import Sanic, response
from sanic_amqp_ext import AmqpExtension, AmqpWorker

app = Sanic(__name__)
# Configuration for RabbitMQ
    "AMQP_USERNAME": "guest",
    "AMQP_PASSWORD": "guest",
    "AMQP_HOST": "localhost",
    "AMQP_PORT": 5672,
    "AMQP_VIRTUAL_HOST": "vhost",
    "AMQP_USING_SSL": False,
AmqpExtension(app) # AMQP is available as `app.amqp` or `app.extensions['amqp']`

class CustomWorker(AmqpWorker):

    async def run(self, *args, **kwargs):
        transport, protocol = await self.connect()  # create a new connection
        # and do some stuff here ...

# Register workers after initializing the extension

async def handle(request):
    transport, protocol = await  # create a new connection
    # do some stuff here ...
    # P.S. but don't forget to close the connection after using
    return response.text("It's works!")


The sanic-amqp-extension is published under BSD license. For more details read LICENSE file.

Real project examples

Open Matchmaking project:

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

sanic-amqp-extension-0.2.0.tar.gz (4.3 kB view hashes)

Uploaded Source

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