Package: django-beanstalkd
django-beanstalkd=================*django-beanstalkd* is a convenience wrapper for the [beanstalkd][beanstalkd][Python Bindings][beanstalkc].With django-beanstalkd, you can code jobs as well as clients in a Django projectwith minimal overhead in your application. Server connections etc. all takeplace in django-beanstalkd and don't unnecessarily clog your application code.This library is based in large part on Fred Wenzel's [django-gearman][django-gearman].If you're looking for synchronous execution of jobs, check out [Gearman][gearman]and Fred's library! Beanstalkd is useful for background processes only.[beanstalkd]: http://kr.github.com/beanstalkd/[beanstalkc]: http://github.com/earl/beanstalkc/[gearman]: http://gearman.org/[django-gearman]: http://github.com/fwenzel/django-gearmanInstallation------------It's the same for both the client and worker instances of your django project:pip install django-beanstalkdAdd ``django_beanstalkd`` to the `INSTALLED_APPS` section of `settings.py`.Specify the following settings in your local settings.py file if your beanstalkdserver isn't accessible on port 11300 of localhost (127.0.0.1):# My beanstalkd serverBEANSTALK_SERVER = '127.0.0.1:11300'  # the default valueIf necessary, you can specify a pattern to be applied to your beanstalk workerfunctions:# beanstalk job name pattern. Namespacing etc goes here. This is the pattern# your jobs will register as with the server, and that you'll need to use# when calling them from a non-django-beanstalkd client.# replacement patterns are:# %(app)s : django app name the job is filed under# %(job)s : job nameBEANSTALK_JOB_NAME = '%(app)s.%(job)s'Workers-------### Registering jobsCreate a file `beanstalk_jobs.py` in any of your django apps, and define as manyjobs as functions as you like. The job must accept a single string argument aspassed by the caller.Mark each of these functions as beanstalk jobs by decorating them with`django_beanstalkd.beanstalk_job`.For an example, look at the `beanstalk_example` app's `benstalk_jobs.py` file.### Starting a workerTo start a worker, run `python manage.py beanstalk_worker`. It will startserving all registered jobs.To spawn more than one worker (if, e.g., most of your jobs are I/O bound),use the `-w` option:python manage.py beanstalk_worker -w 5will start five workers.Since the process will keep running while waiting for and executing jobs,you probably want to run this in a _screen_ session or similar.Clients-------To make your workers work, you need a client app passing data to them. Createand instance of the `django_beanstalkd.BeanstalkClient` class and `call` afunction with it:from django_beanstalkd import BeanstalkClientclient = BeanstalkClient()client.call('beanstalk_example.background_counting', '5')For a live example look at the `beanstalk_example` app, in the`management/commands/beanstalk_example_client.py` file. Arguments to `call` arepriority: an integer number that specifies the priority. Jobs with asmaller priority get executed firstdelay:    how many seconds to wait before the job can be reservedttr:      how many seconds a worker has to process the job before it gets requeuedExample App-----------For a full, working, example application, add `beanstalk_example` to your`INSTALLED_APPS`, then run a worker in one shell:python manage.py beanstalk_worker -w 4and execute the example app in another:python manage.py beanstalk_example_clientYou can see the client sending data and the worker(s) working on it.Licensing---------This software is licensed under the [Mozilla Tri-License][MPL]:***** BEGIN LICENSE BLOCK *****Version: MPL 1.1/GPL 2.0/LGPL 2.1The contents of this file are subject to the Mozilla Public License Version1.1 (the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.mozilla.org/MPL/Software distributed under the License is distributed on an "AS IS" basis,WITHOUT WARRANTY OF ANY KIND, either express or implied. See the Licensefor the specific language governing rights and limitations under theLicense.The Original Code is django-gearman.The Initial Developer of the Original Code is Mozilla.Portions created by the Initial Developer are Copyright (C) 2010the Initial Developer. All Rights Reserved.Contributor(s):Jonas VP <jvp@jonasundderwolf.de>Frederic Wenzel <fwenzel@mozilla.com>Jeff Balogh <me@jeffbalogh.org>Kimi Huang <kimi.huang@brightcells.com>Alternatively, the contents of this file may be used under the terms ofeither the GNU General Public License Version 2 or later (the "GPL"), orthe GNU Lesser General Public License Version 2.1 or later (the "LGPL"),in which case the provisions of the GPL or the LGPL are applicable insteadof those above. If you wish to allow use of your version of this file onlyunder the terms of either the GPL or the LGPL, and not to allow others touse your version of this file under the terms of the MPL, indicate yourdecision by deleting the provisions above and replace them with the noticeand other provisions required by the GPL or the LGPL. If you do not deletethe provisions above, a recipient may use your version of this file underthe terms of any one of the MPL, the GPL or the LGPL.***** END LICENSE BLOCK *****[MPL]: http://www.mozilla.org/MPL/