第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

python redis-queue:文檔中的簡單示例不起作用

python redis-queue:文檔中的簡單示例不起作用

慕標琳琳 2021-09-02 19:22:52
我有兩個文件,實際上是從http://python-rq.org/docs/復制粘貼的:應用程序    from rq import Queue    from redis import Redis    from somewhere import count_words_at_url    import time    # Tell RQ what Redis connection to use    redis_conn = Redis()    q = Queue(connection=redis_conn)  # no args implies the default queue    print(redis_conn)    # Delay execution of count_words_at_url('http://nvie.com')    job = q.enqueue(count_words_at_url, 'http://nvie.com')    print(job.result)   # => None    # Now, wait a while, until the worker is finished    time.sleep(10)    print(job.result)   # => 889某處.pyimport requestsdef count_words_at_url(url):    print("hello?")    resp = requests.get(url)    return len(resp.text.split())我跑了app.py,我得到的輸出是 2 None 值,而不是根據(jù)文檔我應該得到的 889 。我不確定我明白為什么會這樣。我的超時時間是 10 秒,比文檔中的時間長,所以我期待這項工作已經(jīng)完成。我究竟做錯了什么?
查看完整描述

1 回答

?
九州編程

TA貢獻1785條經(jīng)驗 獲得超4個贊

  1. Redis 服務器是否正在運行?

    服務 redis-服務器狀態(tài)

  2. rq worker 正在運行嗎?

    請求信息

如果沒有工人運行,那么


rq worker # run this under the same directory of your project

18:44:54 RQ worker 'rq:worker:ubuntu.45276' started, version 0.12.0

18:44:54 *** Listening on default...

18:44:54 Cleaning registries for queue: default

用更簡單的函數(shù)替換 count_words_at_url,例如


def just_mock(url): time.sleep(5) 返回“{} 的字數(shù)是 ??”.format(url)


查看完整回答
反對 回復 2021-09-02
  • 1 回答
  • 0 關(guān)注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號