python 非同步程式 dramatiq
- 2020 年 1 月 8 日
- 筆記
python 非同步程式 dramatiq
安裝
redis python3.6 -m pip install 'dramatiq[redis, watch]'
程式碼
example.py
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")
執行
// watch . 程式碼 動態檢測 程式碼是否更新,然後自動重啟 dramatiq example --watch .