如果这是一个愚蠢的问题,我道歉并将羞辱我的头,但是:
我正在使用rq在Python中排队作业.我希望它像这样工作:
我的代码到目前为止:
redis_conn = Redis()
use_connection(redis_conn)
q = Queue('normal', connection=redis_conn) # this is terrible, I know - fixing later
w = Worker(q)
job = q.enqueue(getlinksmod.lsGet, theURL,total,domainid)
w.work()
Run Code Online (Sandbox Code Playgroud)
我认为我最好的解决方案是拥有2名工人,一名为工作A,一名为B工作.工作B工人可以监督工作A,当工作A完成时,开始工作B.
我无法想象拯救我的生命是我如何让一个工人监视另一个人的状态.我可以通过job.id从作业A中获取作业ID.我可以使用w.name获取工作者名称.但对于我如何将任何信息传递给其他工作人员并不是最模糊的.
或者,有一个更简单的方法来做到这一点,我完全失踪了?
我通过转换情绪分析脚本来使用它们来教我自己(可能是我的第一个错误)类和方法.
我以为我已经掌握了所有方法,但我一直在努力
global name 'get_bigram_word_feats' is not defined
我相信get_word_feats如果它走得那么远,我也会得到一个错误.
我正在撞击这个伟大的时间.我尝试删除staticmethod并添加自我.我究竟做错了什么?
这是我的代码:
def word_feats(words):
return dict([(word, True) for word in words])
class SentClassifier:
def __init__(self, name, location):
self.name = name
self.location = location
self.fullpath = location + "/" + name
def doesexist(self):
return os.path.isfile(self.fullpath)
def save_classifier(self):
rf = open(self.fullpath, 'wb')
pickle.dump(self.fullpath, rf)
rf.close()
def load_classifier(self):
sf = open(self.fullpath, 'rb')
sclassifier = pickle.load(sf)
sf.close()
return sclassifier
class Training:
def __init__(self, neg, pos):
self.neg = neg
self.pos …Run Code Online (Sandbox Code Playgroud)