Skip to main content

python通用延迟消息队列

Project description

Usage

pip install dqueue

Example

Memory Queue

# memory queue
import threading

from dqueue.queues import MemoryQueue
from dqueue.item import Item

queue = MemoryQueue()

# 模拟不同延迟发布消息
def publisher():
    for i in range(10):
        item = Item(data=f'hello {i}')
        queue.add(item, i * 1000)

# 模拟消费端取延迟消息
def consumer():
    while True:
        messages = queue.get(block=10 * 1000)
        for msg in messages:
            print('message:', msg)


threading.Thread(target=publisher).start()
threading.Thread(target=consumer).start()

Redis Queue

You can continue with the example above and Just change the declare.

from dqueue.queues import RedisQueue

queue = RedisQueue()

# same code

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

dqueue-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

dqueue-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file dqueue-0.1.2.tar.gz.

File metadata

  • Download URL: dqueue-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Darwin/21.4.0

File hashes

Hashes for dqueue-0.1.2.tar.gz
Algorithm Hash digest
SHA256 931d71925fc9e71949cedb4eee36dcca1b9c6d322ecc62e0c6514605025fd25b
MD5 cf36c896af5f1386b78b5dddd9d6e1d0
BLAKE2b-256 da01b4c64030cf3a16e6abe65f8cc6cb45014ed269438db0f6934b62d9f6f583

See more details on using hashes here.

File details

Details for the file dqueue-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dqueue-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Darwin/21.4.0

File hashes

Hashes for dqueue-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bcbe17f2801c4478ebde1742e5bc37ce3e7305b2a2127515cac97db8541672aa
MD5 eebe30cba4171fe01f6415e40fedc015
BLAKE2b-256 bac1d5461c54c26c23799867b4c13c09a43cb65dc93bbb3cc73e1cf9615f4fe7

See more details on using hashes here.

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