Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Utilities for using Beanstalk with Flask

Project description

Utilities for using Beanstalk with Flask


flask_beanstalk.Beanstalk is a simple wrapper for beanstalkc.Connection that allows reading configuration from app.config.

from flask import Flask
from flask_beanstalk import Beanstalk

app = Flask(__name__)
beanstalk = Beanstalk(app)  # or beanstalk.init_app(app)




Define and spawn workers by subclassing from flask_beanstalk.Worker. flask_beanstalk.Worker inherits from gevent.Greenlet but gevent is an optional dependency in case you just want to use the client.

import gevent
from flask_beanstalk import Worker as _Worker

class Worker(_Worker):
  def run(self, job):'Received: %r' % job.body)

workers = Worker.spawn_workers(10)
  while True:
except KeyboardInterrupt:

Try it out

Install and run beanstalkd if you haven’t done so yet.

git clone
cd flask-beanstalk
mkvirtualenv flask-beanstalk
workon flask-beanstalk
python develop

On another terminal:

workon flask-beanstalk

Go to localhost:5000 in your browser to send a job. The worker should be able to accept and process it. Try to send multiple jobs before sending a SIGINT to the worker. Jobs being worked on should be processed first before the worker shuts down.

Project details

Download files

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

Files for Flask-Beanstalk, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size Flask-Beanstalk-0.0.3.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page