Skip to main content

Beanstalkd bindings for python3

Project description


Beanstalk is a simple, fast work queue. Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously

pystalkd is a beanstalkd bindings targeting python3. This library is based on and should be API compatible.

Build Status Installing

pip install pystalkd

or from source:

python install


>>> from pystalkd.Beanstalkd import Connection
>>> c = Connection("localhost", 11300) #if no argument is given default configuration is used
>>> c.put("hey!")
>>> job = c.reserve(0)
>>> job.body

One of the goals is to be API compatible with beanstalkc, so this tutorial should be valid:

The main differences, API wise are:

  1. where number of seconds is expected pystalkd also accepts a timedelta object

  2. you can temporarily watch and use a tube using the with keyword

print(c.using()) # "default"
with c.temporary_use("test"):
  print(c.using()) # "test"
print(c.using()) # "default"

print(c.watching()) # ["default"]
with c.temporary_use("test"):
  print(c.watching()) # ["default", "test"]
print(c.watching()) # ["default"]
  1. you also have access to the "bytes" API. To maintain compatibility with beanstalkc the API worked only with strings but now you can use the functions ending in "_bytes" (internally this is controlled using the raw paramater) to work directly with bytes
from os import urandom
test_bytes = urandom(50)
job_id = c.put_bytes(test_bytes)
job = c.reserve_bytes(0)
print(job.body) # b'i\x91\xdf\xf8\x1b?zj....'

job_id2 = c.put("string")
job2 = c.reserve_bytes(0)
print(job2.body) # b'string'

Note: you can use reserve_bytes with put and get the raw string (not encoded), but the other way around might cause problems


To test with default host and port (localhost, 11300):


To test on a specific host (if port is not specified 11300 is used)

python3 host [port]


Copyright (C) 2008-2014 Andreas Bolka.

Copyright (C) 2015-2016 Gabriel Menezes. Licensed under the MIT.

Project details

Download files

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

Source Distribution

pystalkd-1.3.0.tar.gz (11.6 kB view hashes)

Uploaded source

Built Distribution

pystalkd-1.3.0-py3-none-any.whl (11.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page