本文整理汇总了Python中pyres.ResQ.decode方法的典型用法代码示例。如果您正苦于以下问题:Python ResQ.decode方法的具体用法?Python ResQ.decode怎么用?Python ResQ.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyres.ResQ
的用法示例。
在下文中一共展示了ResQ.decode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_job
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
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() == {}
示例2: all
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
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
示例3: failed_retry
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
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/')
示例4: failed_job
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
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')
示例5: all
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
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
示例6: job
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
def job(self):
data = self.resq.redis.get("resque:worker:%s" % self)
if data:
return ResQ.decode(data)
return {}
示例7: failed_retry
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
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'))
示例8: failed_retry
# 需要导入模块: from pyres import ResQ [as 别名]
# 或者: from pyres.ResQ import decode [as 别名]
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/')