Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A simple tool for creating long-running Python workers listening for Beanstalk jobs.

Project Description

A simple tool for creating long-running Python workers listening for Beanstalk jobs.

Jobs can be posted as YAML or JSON objects, with keys mapping to the callable’s keyword arguments. Passing parse=False to the __init__ method will disable YAML parsing, and the callable will be provided a single string argument containing the job’s body.

Returning True from the callable will be seen as a success and will delete the job from the queue. Returning False or None will be seen as a failure, and the job will be buried for later inspection.

If listening on multiple tubes, add the argument __tubes__ to the method to receive the tube name when the callable is executed.

Usage:

import logging
from RunnerBean import Runner

def print_message(recipient, message, __tube__):
    # accepts a job with the following structure:
    """
    message: Hello world!
    recipient: joe bloggs
    """
    print recipient, message

    print __tube__ #= 'messages'

    return True # this deletes the job from the tube

if __name__ == '__main__':
    runner = Runner(print_message,
                    parse=True, # default; job body should be parsed as YAML
                    tubes="messages", # string or list of tubes to listen on
                    host='0.0.0.0', # beanstalkd host
                    port=11300, # beanstalkd port
                    loglevel=logging.DEBUG, # set log level, default: ERROR
                    logfile='runnerbean.log' # set the logfile
                    )
    runner.run()
Release History

Release History

This version
History Node

0.4.4.dev0

History Node

0.4.3-dev

History Node

0.4.3.dev0

History Node

0.4.2-dev

History Node

0.4.1-dev

History Node

0.4.0-dev

History Node

0.3.3-dev

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
RunnerBean-0.4.4.dev0.tar.gz (4.1 kB) Copy SHA256 Checksum SHA256 Source Feb 20, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting