Skip to main content

Pika plugin module for Bottle microframework

Project description

Bottle-Pika is a plugin that integrates Pika (AMQP) with your Bottle application. It automatically connects to AMQP at the beginning of a request, passes the channel to the route callback and closes the connection and channel afterwards.

To automatically detect routes that need a channel, the plugin searches for route callbacks that require a mq keyword argument (configurable) and skips routes that do not. This removes any overhead for routes that don’t need a message queue.

This plugin was originally based on the bottle-mysql plugin found at:

https://pypi.python.org/pypi/bottle-mysql

Usage Example:

import bottle
import bottle_pika
import pika

app = bottle.Bottle()
pika_plugin = bottle_pika.Plugin(pika.URLParameters('amqp://localhost/'))
app.install(pika_plugin)

@app.route('/hello')
def hello(mq):
    mq.basic_publish(...)
    return HTTPResponse(status=200)
See pika documentation on channels for more information:

http://pika.readthedocs.org/en/latest/modules/channel.html#pika.channel.Channel

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

bottle_pika-0.1.0.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

bottle_pika-0.1.0-py2.7.egg (5.0 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