Flask-Beanstalk
Utilities for using Beanstalk with Flask
Client
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)
Configuration
app.config['BEANSTALK_HOST'] app.config['BEANSTALK_PORT'] app.config['BEANSTALK_PARSE_YAML'] app.config['BEANSTALK_CONN_TIMEOUT']
Worker
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):
self._logger.info('Received: %r' % job.body)
job.delete()
workers = Worker.spawn_workers(10)
try:
while True:
gevent.sleep(10000)
except KeyboardInterrupt:
Worker.stop_workers(workers)
Try it out
Install and run beanstalkd if you haven’t done so yet.
git clone https://github.com/marksteve/flask-beanstalk.git cd flask-beanstalk mkvirtualenv flask-beanstalk workon flask-beanstalk python setup.py develop python example_worker.py
On another terminal:
workon flask-beanstalk python example.py
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.
Metadata
Release files for Flask-Beanstalk 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-Beanstalk-0.0.3.tar.gz | 3.1 kB | Without provenance | Details for Flask-Beanstalk-0.0.3.tar.gz |
Release files / Flask-Beanstalk-0.0.3.tar.gz
| Download URL | Flask-Beanstalk-0.0.3.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddfcd74f8c33c900133a8de4bd3c2da67dede3ce8048fd4cd31e4ea8e9a7aa96
|
|
BLAKE2b-256 checksum How to use checksums |
083f65766093bc9c746b2f8d03fd9cbdc4f352a9222d0239f456270d64610d49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-Beanstalk 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.