python 异步程序 dramatiq

2020-01-08 18:28:42 浏览数 (1)

python 异步程序 dramatiq

安装

代码语言:javascript复制
redis

python3.6 -m pip install 'dramatiq[redis, watch]'

代码

example.py

代码语言:javascript复制
import dramatiq
import requests
from dramatiq.brokers.redis import RedisBroker

redis_broker = RedisBroker(host="127.0.0.1", port=6379)
dramatiq.set_broker(redis_broker)

@dramatiq.actor
def count_words(url):
    print(url)

count_words.send("http://example.com")

执行

代码语言:javascript复制
// watch . 代码 动态检测 代码是否更新,然后自动重启
dramatiq example --watch .        

0 人点赞