Python RQPython隊列服務(wù)
RQ (Redis Queue) 是一個簡單的 Python 庫用于將作業(yè)放到隊列中并在后臺統(tǒng)一執(zhí)行,使用 Redis 做后端,可方便的跟 Web 前端集成。
示例代碼:
import requests
def count_words_at_url(url):
resp = requests.get(url)
return len(resp.text.split())
Then, create a RQ queue:
from rq import Queue, use_connection
use_connection()
q = Queue()
And enqueue the function call:
from my_module import count_words_at_url
result = q.enqueue(
count_words_at_url, 'http://nvie.com')
評論
圖片
表情
