使用python rq作為隊(duì)列,但是參考他們的docs沒(méi)有運(yùn)行成功文件的組織目錄:+ index.py+ test_work| __init__.py| a.pyindex.py 代碼如下:#coding: utf-8import test_workfrom test_work import afrom redis import Redisfrom rq import Queueif __name__=='__main__':
q = Queue(connection = Redis()) x=0 while x<10:
x+=1 z=2000200+x print x
q.enqueue(a.count_words_at_url,'http://book.douban.com/subject/%d/'%z)a.py 代碼如下:#coding: utf-8import requests
def count_words_at_url(url):
resp = requests.get(url) return len(resp.text.split())在運(yùn)行以后總是失敗,在rq-dashboard中查看到的錯(cuò)誤消息: test_work.a.count_words_at_url('http://book.douban.com/subject/2000201/') from defaultd8d8c5ad-3ff9-4212-8e98-339fc5cfcc31
Failed 11 minutes ago
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rq-0.3.5-py2.7.egg/rq/worker.py", line 392, in perform_job
rv = job.perform()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rq-0.3.5-py2.7.egg/rq/job.py", line 340, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rq-0.3.5-py2.7.egg/rq/job.py", line 133, in func
module = importlib.import_module(module_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named test_work.a額……python基礎(chǔ)沒(méi)有打牢,求解~
如下是在運(yùn)行以后總是失敗,在rq-dashboard中查看到的錯(cuò)誤消息:
小怪獸愛(ài)吃肉
2023-04-25 19:15:26