Exemplo n.º 1
0
 def pop(cls, queues, timeout=0):
     if isinstance(queues, basestring):
         queues = [queues]
     ret = cls.client.blpop(["resque:queue:%s" % q for q in queues],
                            timeout=timeout)
     if ret:
         key, ret = ret
         return key[13:], TaskMessage.decode(ret)  # trim "resque:queue:"
     else:
         return None, None
Exemplo n.º 2
0
 def next_item_for_timestamp(cls, timestamp):
     #key = int(time.mktime(timestamp.timetuple()))
     key = "resque:delayed:%s" % timestamp
     ret = cls.client.lpop(key)
     item = None
     if ret:
         item = TaskMessage.decode(ret)
     if cls.client.llen(key) == 0:
         cls.client.delete(key)
         cls.client.zrem('resque:delayed_queue_schedule', timestamp)
     return item
Exemplo n.º 3
0
 def delayed_push(cls, datetime, item):
     key = int(time.mktime(datetime.timetuple()))
     cls.client.rpush('resque:delayed:%s' % key, TaskMessage.encode(item))
     cls.client.zadd('resque:delayed_queue_schedule', key, key)
Exemplo n.º 4
0
 def list_range(cls, key, start, count):
     items = cls.client.lrange(key, start, start + count - 1) or []
     ret_list = []
     for i in items:
         ret_list.append(TaskMessage.decode(i))
     return ret_list
Exemplo n.º 5
0
 def push(cls, queue, item):
     cls.watch_queue(queue)
     cls.client.rpush("resque:queue:%s" % queue, TaskMessage.encode(item))