コード例 #1
0
    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
コード例 #2
0
ファイル: job.py プロジェクト: iuridiniz/thoonk.py
    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        
コード例 #3
0
ファイル: job.py プロジェクト: iuridiniz/thoonk.py
 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))
コード例 #4
0
ファイル: job.py プロジェクト: sjhewitt/thoonk.py
    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))
コード例 #5
0
    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)
コード例 #6
0
ファイル: pyqueue.py プロジェクト: NorthIsUp/thoonk.py
    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)
コード例 #7
0
    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)
コード例 #8
0
ファイル: pyqueue.py プロジェクト: NorthIsUp/thoonk.py
    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)
コード例 #9
0
 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))