Skip to main content

FIFO Queue for Bottle built upon HotQueue

Project description

# bottlehotqueue

_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

$ pip install bottle-hotqueue

### From source:

$ python setup.py install

### Dependencies:

bottle, hotqueue

## Getting Started

### Importing and using the plugin in Bottle

```python
import bottle
from bottlehotqueue import Plugin


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


@app.post('/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 to match the default implementation 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).

```python
hotqueue = Plugin(keyword="myhotqueue", asjson=False)
```

### Writing a simple consumer

```python
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.2.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bottle-hotqueue-0.2.0.linux-i686.tar.gz (3.3 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for bottle-hotqueue-0.2.0.tar.gz
Algorithm Hash digest
SHA256 24b1ea760f41ab5878c523aaf362281d1dcfe833b6b47c150c4e3f0899fa60dd
MD5 0614f7970840aafb8c2102792093677f
BLAKE2b-256 6f7aacf8ba73fb7aac0698cd7d13548f2663cee01f54cd580a545dfddc75427e

See more details on using hashes here.

File details

Details for the file bottle-hotqueue-0.2.0.linux-i686.tar.gz.

File metadata

File hashes

Hashes for bottle-hotqueue-0.2.0.linux-i686.tar.gz
Algorithm Hash digest
SHA256 4204573e4557840a4e6ba3978c0fb09d93863ae83e59b7aebe460954a190a297
MD5 789737ff33e071402410ed7d4f393998
BLAKE2b-256 4ea044ab3c794f1efba1655aa04137de81e5d39da09d6d827927db37721c05aa

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