Dramatiq 是一个Python3(3.5或更高版本)分布式任务处理库,特点是简单、可靠和高性能。
Demo
import dramatiqimport requests@dramatiq.actordef count_words(url): response = requests.get(url) count = len(response.text.split(" ")) print(f"There are {count} words at {url!r}.")# Synchronously count the words on example.com in the current processcount_words("https://example.com")# or send the actor a message so that it may perform the count# later, in a separate process.count_words.send("https://example.com")使用
与 RabbitMQ 一起使用:
$ pip install -U dramatiq[rabbitmq, watch]与 Redis 一起使用:
$ pip install -U dramatiq[redis, watch]具体使用方法阅读 Motivation 或 UserGuide。
评论