Пример #1
0
    def test_25_main_queue_multiple_connections(self):
        queues = []
        for i in range(self.queues):
            queue = Queue(self.queue.name)
            queue.conn_adapter = ConnAdapter(self._connect())
            queues.append(queue)

        stack = []
        for i in range(self.tries):
            queue = queues[i % len(queues)]
            job = {
                'method' : 'Kernel.puts',
                'args' : ["Job %d executed" % i],
            }
            queue.enqueue(job['method'], job['args'])
            stack.append(job)

        for i in range(self.tries):
            queue = queues[i % len(queues)]
            got = self.queue.lock()
            self.assertIsNotNone(got)
            try:
                stack.remove(dict(method=got['method'], args=got['args']))
                # NOTE: problems appears if you don't delete the job
                queue.delete(got['id'])
            except ValueError:
                self.fail("can't remove item %s from the stack" % repr(got))
Пример #2
0
    def test_30_multiple_queue_multiple_connections(self):
        queues = []
        for i in range(self.queues):
            queue = Queue("queue_%03d" % i)
            queue.conn_adapter = ConnAdapter(self._connect())
            queues.append(queue)

        stack = []
        for i in range(self.tries):
            queue = queues[i % len(queues)]
            job = ('Kernel.puts', ["Job %d executed" % i])
            queue.enqueue(*job)
            stack.append(job)

        for i in range(self.tries):
            queue = queues[i % len(queues)]
            got = queue.lock()
            self.assertIsNotNone(got)
            try:
                stack.remove((got['method'], got['args']))
                # TODO: Problems appears if you don't delete the job
                queue.delete(got['id'])
            except ValueError:
                self.fail("can't remove item %s in stack" % got)