Skip to main content

Forked from and based on https://github.com/Relrin/sanic-amqp-extension (sanic-amqp-extension) Extensions were forked and modified to keep the code updated with the latest version of dependecnies and to add additional functionality

sanic-amqp

AMQP support for Sanic framework

Features

  • Based on the aioamqp library

  • Provides an opportunity to implement workers that works in background

Installation

This package should be installed using pip:

pip install sanic-amqp

Example

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


app = Sanic(__name__)
# Configuration for RabbitMQ
app.config.update({
    "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
app.amqp.register_worker(CustomWorker(app))


@app.route("/")
async def handle(request):
    transport, protocol = await request.app.amqp.connect()  # 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!")

License

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

Metadata

Release files for sanic-amqp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for sanic-amqp 0.2.0
File Interpreter ABI Platform Actions
sanic_amqp-0.2.0-py3-none-any.whl Python 3 none any Details for sanic_amqp-0.2.0-py3-none-any.whl

Release files / sanic_amqp-0.2.0-py3-none-any.whl

Download URL sanic_amqp-0.2.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
790792577c82f2dc4e0ddad598222c1373f2a4cadd072fd47ba98e8abe80c738
BLAKE2b-256 checksum
How to use checksums
af4c5a830c324fe033fed8dae5e935c28f3e92ad6b9612ba9d04ec326b5f718e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

Security for sanic-amqp 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page