A distributed queue based on Redis.
Project description
A distributed queue based on Redis
Installation
pip install redque
Example
import time
import random
import threading
import redis
import redque
def productor(redis_conn):
other_queue = redque.Queue(redis_conn, "__test", "bp__test")
for _ in range(100):
other_queue.push("e_{0}".format(random.randint(1, 100)))
time.sleep(0.1)
if __name__ == "__main__":
pool = redis.ConnectionPool(
host="127.0.0.1",
port=6379,
password="123456"
)
queue = redque.Queue(
redis.Redis(connection_pool=pool),
"__test",
"bp__test"
)
queue.clear(True)
# non-blocking
for _ in range(100):
queue.push(random.randint(1, 100))
queue.process(lambda x: (print(x), True), False)
# blocking
t = threading.Thread(target=productor,
args=(redis.Redis(connection_pool=pool),))
t.start()
queue.process(lambda x: (print(x), True), timeout=3)
t.join()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redque-0.1.0.tar.gz
(2.6 kB
view details)
Built Distribution
File details
Details for the file redque-0.1.0.tar.gz
.
File metadata
- Download URL: redque-0.1.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
1e2dac63d8453b6d5f49aa7ec3a085e6a8356ae63d05bdcbe41fbfc3276fdb16
|
|
MD5 |
d3a5d17f766eb49bba3faf5d282416ff
|
|
BLAKE2b-256 |
274c3259e7da7395d765cda5cc50dcb9718dacf7b575ca9526d9362bf8145af2
|
File details
Details for the file redque-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: redque-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9398b35dab574b2300a756503f9db8418ef250ef54e9ca4940dd9439125464d3
|
|
MD5 |
b8ee31cebadacdbbd0f52865c77fa788
|
|
BLAKE2b-256 |
8d9b6162fd0fb3934c2a008d1ef58ec9e4461f03e3d1d986801e1e63591a5281
|