Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oldhammade/runnerbean
Simple tool for creating workers for beanstalk jobs
https://github.com/oldhammade/runnerbean
Last synced: about 6 hours ago
JSON representation
Simple tool for creating workers for beanstalk jobs
- Host: GitHub
- URL: https://github.com/oldhammade/runnerbean
- Owner: OldhamMade
- Created: 2011-04-06T11:44:54.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2015-02-20T16:44:36.000Z (over 9 years ago)
- Last Synced: 2024-11-10T09:07:28.172Z (6 days ago)
- Language: Python
- Homepage:
- Size: 274 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
RunnerBean
==========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 Runnerdef print_message(recipient, message, __tube__):
# accepts a job with the following structure:
"""
message: Hello world!
recipient: joe bloggs
"""
print recipient, messageprint __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()