コード例 #1
0
ファイル: queue.py プロジェクト: dwoos/resched
    def __init__(self, redis_client, namespace, content_type=ContentType.STRING, **kwargs):
        """
        @param  redis_client       the redis.py client to use
        @param  namespace          the 'name' of this Queue
        @param  content_type       A resched.ContentType, defaulting to STRING

        @optional  worker_id       defaults to 'global', but useful if doing multi-processing
        @optional  track_entries   whether to keep a set around to track membership, defaults to False
        @optional  strategy        'filo' or 'fifo', defaults to 'fifo'
        @optional  work_ttl        work_ttl_seconds
        @optional  pipes           A list of KV pairs of completion result keys and resultant Queues.
        """
        RedisBacked.__init__(self, redis_client, namespace, content_type, **kwargs)
        self.worker_id = kwargs.get('worker_id', 'global')
        self.strategy = kwargs.get('strategy', self.FIFO)
        assert self.strategy in (self.FIFO, self.LIFO)
        self.keep_entry_set = kwargs.get('track_entries', False)
        self.keep_working_entry_set = kwargs.get('track_working_entries', True)
        self.work_ttl_seconds = kwargs.get('work_ttl', self.DEFAULT_WORK_TTL_SECONDS)
        self.pipes = dict(kwargs.get('pipes', []))
        self.track_add_attempts = kwargs.get('track_add_attempts', False)
        for result_code, queue in self.pipes.iteritems():
            assert isintance(result_code, basestring) and isinstance(queue, Queue)

        self.QUEUE_LIST_KEY = 'queue.{ns}'.format(ns=namespace)
        self.ENTRY_SET_KEY = 'queue.{ns}.entries'.format(ns=namespace)
        self.WORKER_SET_KEY = 'queue.{ns}.workers'.format(ns=namespace)
        self.WORKING_LIST_KEY = self._working_list_key()
        self.WORKING_ACTIVE_KEY = self._working_active_key()
        self.PAYLOADS = 'queue.{ns}.payload'.format(ns=namespace)
        self.ADD_ATTEMPTS_SET = 'queue.{ns}.attempts'.format(ns=namespace)
コード例 #2
0
ファイル: scheduler.py プロジェクト: inlinestyle/resched
 def __init__(self, redis_client, namespace, content_type):
     """
     Create a scheduler, in a namespace.
     """
     RedisBacked.__init__(self, redis_client, namespace, content_type)
     self.SCHEDULED = 'schedule:{0}:waiting'.format(namespace)
     self.INPROGRESS = 'schedule:{0}:inprogress'.format(namespace)
     self.PAYLOADS = 'schedule:{0}:payload'.format(namespace)
     self.EXPIRATIONS = 'schedule:{0}:expiration'.format(namespace)
     self.VERSION = 'schedule:{0}:version'.format(namespace)
     self.WORKING_TTL = 'schedule:{0}:working'.format(namespace)
コード例 #3
0
 def __init__(self, redis_client, namespace, content_type):
     """
     Create a scheduler, in a namespace.
     """
     RedisBacked.__init__(self, redis_client, namespace, content_type)
     self.SCHEDULED = 'schedule:{0}:waiting'.format(namespace)
     self.INPROGRESS = 'schedule:{0}:inprogress'.format(namespace)
     self.PAYLOADS = 'schedule:{0}:payload'.format(namespace)
     self.EXPIRATIONS = 'schedule:{0}:expiration'.format(namespace)
     self.VERSION = 'schedule:{0}:version'.format(namespace)
     self.WORKING_TTL = 'schedule:{0}:working'.format(namespace)
コード例 #4
0
ファイル: queue.py プロジェクト: inlinestyle/resched
 def __init__(self, redis_client, namespace, content_type, **kwargs):
     """
     optional kwargs:
     worker_id:       defaults to 'global', but useful if doing multi-processing
     track_entries:   whether to keep a set around to track membership, defaults to False
     strategy:        'filo' or 'fifo', defaults to 'fifo'
     work_ttl:        work_ttl_seconds
     """
     RedisBacked.__init__(self, redis_client, namespace, content_type, **kwargs)
     self.worker_id = kwargs.get('worker_id', 'global')
     self.QUEUE_LIST_KEY = 'queue.{ns}'.format(ns=namespace)
     self.ENTRY_SET_KEY = 'queue.{ns}.entries'.format(ns=namespace)
     self.WORKER_SET_KEY = 'queue.{ns}.workers'.format(ns=namespace)
     self.WORKING_LIST_KEY = 'queue.{ns}.working.{wid}'.format(ns=namespace, wid=self.worker_id)
     self.WORKING_ACTIVE_KEY = 'queue.{ns}.active.{wid}'.format(ns=namespace, wid=self.worker_id)
     self.PAYLOADS = 'queue.{ns}.payload'.format(ns=namespace)
     self.strategy = kwargs.get('strategy', self.FIFO)
     self.keep_entry_set = kwargs.get('track_entries', False)
     self.work_ttl_seconds = kwargs.get('work_ttl', self.DEFAULT_WORK_TTL_SECONDS)
コード例 #5
0
ファイル: queue.py プロジェクト: szaydel/resched
    def __init__(self,
                 redis_client,
                 namespace,
                 content_type=ContentType.STRING,
                 **kwargs):
        """
        @param  redis_client       the redis.py client to use
        @param  namespace          the 'name' of this Queue
        @param  content_type       A resched.ContentType, defaulting to STRING

        @optional  worker_id       defaults to 'global', but useful if doing multi-processing
        @optional  track_entries   whether to keep a set around to track membership, defaults to False
        @optional  strategy        'filo' or 'fifo', defaults to 'fifo'
        @optional  work_ttl        work_ttl_seconds
        @optional  pipes           A list of KV pairs of completion result keys and resultant Queues.
        """
        RedisBacked.__init__(self, redis_client, namespace, content_type,
                             **kwargs)
        self.worker_id = kwargs.get('worker_id', 'global')
        self.strategy = kwargs.get('strategy', self.FIFO)
        assert self.strategy in (self.FIFO, self.LIFO)
        self.keep_entry_set = kwargs.get('track_entries', False)
        self.keep_working_entry_set = kwargs.get('track_working_entries', True)
        self.work_ttl_seconds = kwargs.get('work_ttl',
                                           self.DEFAULT_WORK_TTL_SECONDS)
        self.pipes = dict(kwargs.get('pipes', []))
        self.track_add_attempts = kwargs.get('track_add_attempts', False)
        for result_code, queue in self.pipes.iteritems():
            assert isintance(result_code, basestring) and isinstance(
                queue, Queue)

        self.QUEUE_LIST_KEY = 'queue.{ns}'.format(ns=namespace)
        self.ENTRY_SET_KEY = 'queue.{ns}.entries'.format(ns=namespace)
        self.WORKER_SET_KEY = 'queue.{ns}.workers'.format(ns=namespace)
        self.WORKING_LIST_KEY = self._working_list_key()
        self.WORKING_ACTIVE_KEY = self._working_active_key()
        self.PAYLOADS = 'queue.{ns}.payload'.format(ns=namespace)
        self.ADD_ATTEMPTS_SET = 'queue.{ns}.attempts'.format(ns=namespace)