Notes on Python and beanstalkd on Ubuntu Karmic
BeanstalkInstall and run beanstalkd
Reference: beanstalkd README
- Install dependencies (libevent 1.4.1+)
$ sudo apt-get update $ sudo apt-get install libevent-1.4-2 libevent-dev
- Download and unpack beanstalkd
$ curl http://xph.us/dist/beanstalkd/beanstalkd-1.4.4.tar.gz | tar zx - Build
$ cd beanstalkd-1.4.4 $ ./configure $ make
- Run the beanstalkd server
$ ./beanstalkd -d -l 127.0.0.5 -p 11300
Install the Python client library
- Install pip
- Install PyYAML (beanstalkc
dependency)
$ sudo apt-get build-dep python-yaml $ sudo pip install PyYAML
- Install beanstalkc
$ sudo pip install beanstalkc
Example
Reference: beanstalkc TUTORIAL
import beanstalkc
# connect to server
bean = beanstalkc.Connection(host='127.0.0.5', port=11300)
# put jobs in queue
for i in range(5):
print 'Put data: %d' % i
bean.put(str(i))
# get jobs from queue
while True:
job = bean.reserve()
print 'Got data: %s' % job.body
job.delete()
Results:
Put data: 0 Put data: 1 Put data: 2 Put data: 3 Put data: 4 Got data: 0 Got data: 1 Got data: 2 Got data: 3 Got data: 4
Post a comment
About
I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »
Search Blog
Tags
-
algorithms
(5)
-
aws
(9)
-
blogproject
(20)
-
c_cplusplus
(12)
-
cardstore
(8)
-
colinux
(2)
-
concurrency
(13)
-
conkeror
(2)
-
core
(2)
-
cygwin
(17)
-
datastructures
(14)
-
datetime
(4)
-
decorators
(4)
-
django
(40)
-
emacs
(22)
-
files_directories
(11)
-
git
(5)
-
hardware
(5)
-
install_setup
(8)
-
javascript
(3)
-
keyboard
(9)
-
matplotlib
(5)
-
mercurial
(4)
-
nginx
(2)
-
persistence
(5)
-
preferences
(7)
-
processes
(4)
-
pyqt
(18)
-
python
(144)
-
ratpoison
(3)
-
regexes
(6)
-
rsync
(3)
-
softwaretools
(17)
-
sql
(14)
-
ssh
(10)
-
subversion
(6)
-
twisted
(7)
-
ubuntu
(65)
-
urxvt
(5)
-
vxworks
(25)
-
webdev
(5)
-
wmii
(7)
Blogroll
- Adam Gomaa
- Alex Clemesha
- Amir Salihefendic
- Armin Ronacher
- David Beazley
- David Ziegler
- Duncan McGreggor
- Gareth Rushgrave
- Glyph Lefkowitz
- Guido van Rossum
- Ian Bicking
- Jacob Kaplan-Moss
- James Bennett
- James Tauber
- Jesper Noehr
- Marty Alchin
- Matt Harrison
- Nikolay Kolev
- Parand Darugar
- Peter Baumgartner
- Peter Bengtsson
- Rob Hudson
- Simon Willison
- Will McGugan