コード例 #1
0
    def wait(self, wait_time=0):
        """
        Returns a :class:`~retask.task.Task` object from the queue. Returns ``False`` if it timeouts.

        :arg wait_time: Time in seconds to wait, default is infinite.

        :return: :class:`~retask.task.Task` object from the queue or False if it timeouts.

        .. doctest::

           >>> from retask import Queue
           >>> q = Queue('test')
           >>> q.connect()
           True
           >>> task = q.wait()
           >>> print task.data
           {u'name': u'kushal'}

        .. note::

            This is a blocking call, you can specity wait_time argument for timeout.

        """
        if not self.connected:
            raise ConnectionError('Queue is not connected')

        data = self.rdb.brpop(self._name, wait_time)
        if data:
            task = Task()
            task.__dict__ = json.loads(data[1])
            return task
        else:
            return False
コード例 #2
0
    def dequeue(self):
        """
        Returns a :class:`~retask.task.Task` object from the queue. Returns ``None`` if the
        queue is empty.

        :return: :class:`~retask.task.Task` object from the queue

        If the queue is not connected then it will raise
        :class:`retask.ConnectionError`

        .. doctest::

           >>> from retask import Queue
           >>> q = Queue('test')
           >>> q.connect()
           True
           >>> t = q.dequeue()
           >>> print t.data
           {u'name': u'kushal'}

        """
        if not self.connected:
            raise ConnectionError('Queue is not connected')

        if self.rdb.llen(self._name) == 0:
            return None

        data = self.rdb.rpop(self._name)
        if not data:
            return None
        if isinstance(data, six.binary_type):
            data = six.text_type(data, 'utf-8', errors='replace')
        task = Task()
        task.__dict__ = json.loads(data)
        return task
コード例 #3
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    def dequeue(self):
        """
        Returns a :class:`~retask.task.Task` object from the queue. Returns ``None`` if the
        queue is empty.

        :return: :class:`~retask.task.Task` object from the queue

        If the queue is not connected then it will raise
        :class:`retask.ConnectionError`

        .. doctest::

           >>> from retask import Queue
           >>> q = Queue('test')
           >>> q.connect()
           True
           >>> t = q.dequeue()
           >>> print t.data
           {u'name': u'kushal'}

        """
        if not self.connected:
            raise ConnectionError('Queue is not connected')

        if self.rdb.llen(self._name) == 0:
            return None

        data = self.rdb.rpop(self._name)
        if not data:
            return None
        if isinstance(data, six.binary_type):
            data = six.text_type(data, 'utf-8', errors = 'replace')
        task = Task()
        task.__dict__ = json.loads(data)
        return task
コード例 #4
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    def wait(self, wait_time=0):
        """
        Returns a :class:`~retask.task.Task` object from the queue. Returns ``False`` if it timeouts.

        :arg wait_time: Time in seconds to wait, default is infinite.

        :return: :class:`~retask.task.Task` object from the queue or False if it timeouts.

        .. doctest::

           >>> from retask import Queue
           >>> q = Queue('test')
           >>> q.connect()
           True
           >>> task = q.wait()
           >>> print task.data
           {u'name': u'kushal'}

        .. note::

            This is a blocking call, you can specity wait_time argument for timeout.

        """
        if not self.connected:
            raise ConnectionError('Queue is not connected')

        data = self.rdb.brpop(self._name, wait_time)
        if data:
            task = Task()
            task.__dict__ = json.loads(data[1])
            return task
        else:
            return False
コード例 #5
0
    def setUp(self):
        self.queue = PriorityQueue('get_reverse_test_queue', reverse_order=True)
        self.queue.connect()

        self.queue.enqueue(Task({'index': 2}), 50)
        self.queue.enqueue(Task({'index': 0}), 25)
        self.queue.enqueue(Task({'index': 1}), 40)
        self.queue.enqueue(Task({'index': 3}), 100)
コード例 #6
0
    def setUp(self):
        self.queue = PriorityQueue('get_test_queue')
        self.queue.connect()

        self.queue.enqueue(Task({'index': 1}), 50)
        self.queue.enqueue(Task({'index': 3}), 25)
        self.queue.enqueue(Task({'index': 2}), 40)
        self.queue.enqueue(Task({'index': 0}), 100)
コード例 #7
0
def find_builds(oldid, newid):
    """

    :param oldid: The id to start from
    :param newid: The id to end
    :return: None
    """
    koji_session = koji.ClientSession("http://koji.fedoraproject.org/kojihub/")

    config = get_redis_config()
    jobqueue = Queue('jobqueue', config)
    jobqueue.connect()

    for i in range(oldid, newid + 1):
        build_rpms = koji_session.listBuildRPMs(i)
        if build_rpms:
            r1 = build_rpms[0]
            release = r1['release'].split('.')[-1]
            if release == 'el5':
                continue
            print i, release  # Enqueue the job here.
            info = {
                'build_id': i,
                'instance': 'primary',
                'release': release,
            }

            task = Task(info)
            enqueue(task)
        else:
            print "Missing: ", i
コード例 #8
0
ファイル: queue.py プロジェクト: pranjal5215/fastQ
    def put(self, data):
        """
        Create a task from data and put it to Queue.

        Args:
            data: A dictionary.
        """
        task = Task(data)
        job = self.q.enqueue(task)
        return job
コード例 #9
0
        Generic.Output: "#888",  # class: 'go'
        Generic.Prompt: "#745334",  # class: 'gp'
        Generic.Strong: "bold #000000",  # class: 'gs'
        Generic.Subheading: "bold #800080",  # class: 'gu'
        Generic.Traceback: "bold #a40000",  # class: 'gt'
    }


########NEW FILE########
__FILENAME__ = async_producer
from retask import Task
from retask import Queue
import time
queue = Queue('example')
info1 = {'user': '******', 'url': 'http://planet.fedoraproject.org'}
task1 = Task(info1)
queue.connect()
job = queue.enqueue(task1)
print job.result
time.sleep(30)
print job.result

########NEW FILE########
__FILENAME__ = async_worker
from retask import Queue
import time
queue = Queue('example')
queue.connect()
task = queue.wait()
print task.data
time.sleep(15)
コード例 #10
0
from retask import Task
from retask import Queue
import time
queue = Queue('example')
info1 = {'user': '******', 'url': 'http://planet.fedoraproject.org'}
task1 = Task(info1)
queue.connect()
job = queue.enqueue(task1)
print job.result
time.sleep(30)
print job.result
コード例 #11
0
 def addTask2(self):
     self.queue.enqueue(Task({'text': 'waiting2'}), 20)
コード例 #12
0
 def addTask(self):
     self.queue.enqueue(Task({'text': 'timeout ...'}), 10)
コード例 #13
0
 def runTest(self):
     t = Task({'name': 'josep'})
     self.assertTrue(self.queue.enqueue(t, 100))
コード例 #14
0
 def runTest(self):
     queue = Queue('testqueue')
     queue.connect()
     t = Task({'name': 'kushal'})
     self.assertTrue(queue.enqueue(t))
コード例 #15
0
 def addTask1(self):
     self.queue.enqueue(Task({'text': 'waiting1'}), 10)
コード例 #16
0
 def setUp(self):
     queue = Queue('testqueue')
     queue.connect()
     t = Task({'name': 'kushal'})
     queue.enqueue(t)
コード例 #17
0
ファイル: utils.py プロジェクト: mortbauer/foamserver
 def queue(self,doc):
     self._queue.enqueue(Task(json.dumps(doc,cls=DictEncoder),raw=True))