def __init__(self, thoonk, feed): """ Create a new Job queue object for a given Thoonk feed. Note: More than one Job queue objects may be create for the same Thoonk feed, and creating a Job queue object does not automatically generate the Thoonk feed itself. Arguments: thoonk -- The main Thoonk object. feed -- The name of the feed. config -- Optional dictionary of configuration values. """ Queue.__init__(self, thoonk, feed) self.feed_publishes = 'feed.publishes:%s' % feed self.feed_published = 'feed.published:%s' % feed self.feed_cancelled = 'feed.cancelled:%s' % feed self.feed_retried = 'feed.retried:%s' % feed self.feed_finishes = 'feed.finishes:%s' % feed self.feed_claimed = 'feed.claimed:%s' % feed self.feed_stalled = 'feed.stalled:%s' % feed self.feed_running = 'feed.running:%s' % feed self.job_finish = 'job.finish:%s' % feed
def get_schemas(self): """Return the set of Redis keys used exclusively by this feed.""" schema = set((self.feed_claimed, self.feed_stalled, self.feed_running, self.feed_publishes, self.feed_cancelled)) return schema.union(Queue.get_schemas(self))
def get_schemas(self): """Return the set of Redis keys used exclusively by this feed.""" schema = set((self.feed_job_claimed, self.feed_job_stalled, self.feed_job_running, self.feed_publishes, self.feed_cancelled)) for id in self.get_ids(): schema.add(self.feed_job_finished % id) return schema.union(Queue.get_schemas(self))
def get(self, timeout=0): """ Retrieve the next item from the queue. Raises a self.Empty exception if the request times out. The item will be unpickled before returning. Arguments: timeout -- Optional time in seconds to wait before raising an exception. """ value = Queue.get(self, timeout) return pickle.loads(value)
def get(self, timeout=0): """ Retrieve the next item from the queue. Raises a self.Empty exception if the request times out. The item will be unpickled before returning. Arguments: timeout -- Optional time in seconds to wait before raising an exception. """ value = Queue.get(self, timeout) return cPickle.loads(value)
def put(self, item, priority=None): """ Add a new item to the queue. The item will be pickled before insertion into the queue. (Same as self.publish()) Arguments: item -- The content to add to the queue. priority -- Optional priority; if equal to self.HIGH then the item will be inserted at the head of the queue instead of the end. """ item = pickle.dumps(item) return Queue.put(self, item, priority)
def put(self, item, priority=None): """ Add a new item to the queue. The item will be pickled before insertion into the queue. (Same as self.publish()) Arguments: item -- The content to add to the queue. priority -- Optional priority; if equal to self.HIGH then the item will be inserted at the head of the queue instead of the end. """ item = cPickle.dumps(item) return Queue.put(self, item, priority)