pystalkd
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
http://kr.github.io/beanstalkd/
pystalkd is a beanstalkd bindings targeting python3. This library is based on https://github.com/earl/beanstalkc and should be API compatible.
Installing
pip install pystalkd
or from source:
python setup.py install
Using
>>> 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
"hey!"
One of the goals is to be API compatible with beanstalkc, so this tutorial should be valid: https://github.com/earl/beanstalkc/blob/master/TUTORIAL.mkd
The main differences, API wise are:
-
where number of seconds is expected pystalkd also accepts a timedelta object
-
you can temporarily watch and use a tube using the
withkeyword
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"]
- 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
rawparamater) 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
Tests
To test with default host and port (localhost, 11300):
python3 test.py
To test on a specific host (if port is not specified 11300 is used)
python3 test.py host [port]
License
Copyright (C) 2008-2014 Andreas Bolka.
Copyright (C) 2015-2016 Gabriel Menezes. Licensed under the MIT.
Metadata
Release files for pystalkd 1.3.0
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 |
|---|---|---|---|---|
| pystalkd-1.3.0.tar.gz | 11.6 kB | Without provenance | Details for pystalkd-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pystalkd-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for pystalkd-1.3.0-py3-none-any.whl |
Total release size: 23.0 kB
Release files / pystalkd-1.3.0.tar.gz
| Download URL | pystalkd-1.3.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8ba5b7801ecd812143046fb2d76fa83d161e9fce5d6996bd32d046e22fb211b
|
|
BLAKE2b-256 checksum How to use checksums |
2f4f3ce533d50aa6a55b105ce209c0dc14f68c66553e20cc83bcbf9d88741ff0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4
|
Release files / pystalkd-1.3.0-py3-none-any.whl
| Download URL | pystalkd-1.3.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
810bd9727f49fbd736fb560daf5525b73227eda870216881909c76b73675c814
|
|
BLAKE2b-256 checksum How to use checksums |
cf6698f0a84934216420b4c681a020dd9f66c66807ea641df0fb5e0258635b8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4
|
Security for pystalkd 1.3.0
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.