Skip to main content

FIFO Queue for Bottle built upon HotQueue

Project description

bottle-hotqueue

FIFO message queue_ plugin for _bottle.py based on HotQueue

bottle.py http://bottlepy.org) is a fast and simple micro-framework for python web-applications.

HotQueue http://richardhenry.github.com/hotqueue/ is a Python library that allows you to use Redis as a message queue within your Python programs.

## Installation

$ sudo pip install bottle-hotqueue

### From source:

$ sudo python setup.py install

### Dependencies:

bottle, hotqueue

## Getting Started

### Importing and using the plugin in Bottle


import bottle
from bottle_hotqueue import HotQueuePlugin


app = bottle.Bottle()
hotqueue = HotQueuePlugin(keyword="myhotqueue")
app.install(hotqueue)


@app.get('/add/:value', myhotqueue={'queue': 'myqueue'})
def send_message(value, myqueue):
""" This will put an item in the queue hotqueue:myqueue.
"""
return myqueue.put(value)


@app.get('/', myhotqueue={'queue': 'myqueue'})
def get_message(myqueue):
""" We will now try to get a item from hotqueue:myqueue.
if the queue is empty, we instead raise a 404.
"""
result = myqueue.get()
if not result:
raise bottle.HTTPError(404, "Queue is Empty")
return result

bottle.run(app, host='', port=8080)


The plugin will use json (or simplejson if available) as the standard serializer. This behaviour can be reverted by passing asjson=False when instantiating the plugin. It will then conform to the standard HotQueue way of serializing objects by using pickle (or cpickle if available).


hotqueue = HotQueuePlugin(keyword="myhotqueue", asjson=False)


### Writing a simple consumer


import json
from hotqueue import HotQueue


queue = HotQueue("myqueue", host="localhost", serializer=json)

for item in queue.consume():
print item


More on HotQueue: http://richardhenry.github.com/hotqueue/

### License
MIT

### Github links
* https://github.com/defnull/bottle
* https://github.com/richardhenry/hotqueue

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-hotqueue-0.1.3.tar.gz (1.5 kB view details)

Uploaded Source

File details

Details for the file bottle-hotqueue-0.1.3.tar.gz.

File metadata

File hashes

Hashes for bottle-hotqueue-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9bc4ac3a988abe247b94ba5cb19e208aef78ccb67808dcf895ef2506d81aec54
MD5 f6fa96877738f4f3e93597eebdbc41e6
BLAKE2b-256 93dd59e7ab3a546885ec717d4e3e8606d4dd215afe8b17191cbefb36d981f340

See more details on using hashes here.

Supported by

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