跳转到主要内容

queued的客户端。

项目描述

Python客户端用于HTTP消息队列Queued: https://github.com/scttnlsn/queued.

用法

>>> import pyqueued

获取客户端。

>>> client = pyqueued.Client(host='localhost', port=5353)

入队消息

>>> loc = client.enqueue("q", "my message")
>>> loc
'http://localhost:5353/q/155'

获取队列头部。如果没有超时,当出队时项目会被标记为完成。

>>> msg, loc = client.dequeue("q")
>>> msg
'my message'

现在队列为空,因此另一个出队操作将失败

>>> msg, loc = client.dequeue("q")
...
RuntimeError: dequeue failed: <Response [404]>

入队另一个消息

>>> loc = client.enqueue("q", "another message")

但带有超时(以秒为单位)出队。如果消息在指定的超时时间内未完成,它将被重新入队。

>>> client.dequeue("q", timeout=2)
('another message', 'http://localhost:5353/q/160')

有消息超时并已被重新入队。因此我们可以再次出队它。但现在我们按时标记它完成。

>>> client.dequeue("q", timeout=20)
('my message with timeout', 'http://localhost:5353/q/160')
>>> client.complete("q", "160")

或者,可以通过URL完成项目。最后一行也被写成:

>>> client.complete_by_url('http://localhost:5353/q/160')

队列的统计信息

>>> client.stats("q")
{'depth': 1, 'dequeued': 3, 'enqueued': 3, 'timeouts': 1}

项目详情


下载文件

为您的平台下载文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码发行版

pyqueued-0.1.4.tar.gz (2.2 kB 查看散列值)

上传时间: 源代码

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面