def test_get_job(self): worker = Worker(['basic']) self.resq.enqueue(Basic,"test1") job = Job.reserve('basic', self.resq) worker.working_on(job) name = "%s:%s:%s" % (os.uname()[1],os.getpid(),'basic') assert worker.job() == ResQ.decode(self.redis.get('resque:worker:%s' % name)) assert worker.processing() == ResQ.decode(self.redis.get('resque:worker:%s' % name)) worker.done_working() w2 = Worker(['basic']) print w2.job() assert w2.job() == {}
def test_get_job(self): worker = Worker(['basic']) self.resq.enqueue(Basic,"test1") job = Job.reserve('basic', self.resq) worker.working_on(job) name = "%s:%s:%s" % (os.uname()[1],os.getpid(),'basic') assert worker.job() == ResQ.decode(self.redis.get('resque:worker:%s' % name)) assert worker.processing() == ResQ.decode(self.redis.get('resque:worker:%s' % name)) worker.done_working(job) w2 = Worker(['basic']) print w2.job() assert w2.job() == {}
def all(cls, resq, start=0, count=1): items = resq.redis.lrange('resque:failed', start, count) or [] ret_list = [] for i in items: failure = ResQ.decode(i) failure['redis_value'] = b64encode(i) ret_list.append(failure) return ret_list
def failed_retry(request): try: import json except ImportError: import simplejson as json failed_job = request.POST['failed_job'] job = b64decode(failed_job) decoded = ResQ.decode(job) failure.retry(HOST, decoded['queue'], job) raise Redirect('/failed/')
def failed_job(request, retry=False): failed_job_ = request.POST['failed_job'] job = b64decode(failed_job_) if retry: # post /failed/retry decoded = ResQ.decode(job) failure.retry(get_pyres(), decoded['queue'], job) else: # post /failed/delete failure.delete(get_pyres(), job) return redirect('resweb-failed')
def all(cls, resq, start=0, count=1): """Get a list of the items in the failure queue. Redis' documentation: `LLEN <http://redis.io/commands/LLEN>`_ :param resq: The redis queue instance to check :type resq: :class:`ResQ` :param start: The location in the queue to start checking at. :type start: int :param count: The number of items to retrieve :type count: int :returns: A list of items in the queue :rtype: `list` of `dict` """ items = resq.redis.lrange('resque:failed', start, count) or [] ret_list = [] for i in items: failure = ResQ.decode(i) failure['redis_value'] = b64encode(i) ret_list.append(failure) return ret_list
def job(self): data = self.resq.redis.get("resque:worker:%s" % self) if data: return ResQ.decode(data) return {}
def failed_retry(): failed_job = request.form['failed_job'] job = b64decode(failed_job) decoded = ResQ.decode(job) failure.retry(g.pyres, decoded['queue'], job) return redirect(url_for('.failed'))
def failed_retry(request): failed_job = request.POST['failed_job'] job = b64decode(failed_job) decoded = ResQ.decode(job) failure.retry(HOST, decoded['queue'], job) raise Redirect('/failed/')
def job(self): data = self.resq.redis.get(self.namespace + ":worker:%s" % self) if data: return ResQ.decode(data) return {}