예제 #1
0
    def test_join_memory_and_disk(self):
        q = OrderedCachedQueue(maxsize=2)
        for x in range(10):
            q.put(create_simple_fuzzable_request(x))

        def queue_get_after_delay(queue):
            time.sleep(1)

            for x in range(2):
                queue.get()
                queue.task_done()

            time.sleep(1)

            for x in range(8):
                queue.get()
                queue.task_done()

        t = threading.Thread(target=queue_get_after_delay,
                             args=(q,))
        t.start()

        start = time.time()

        # This should take 3 seconds
        q.join()

        spent = time.time() - start

        self.assertGreater(spent, 2)
예제 #2
0
    def test_join_memory(self):
        q = OrderedCachedQueue(maxsize=2)
        q.put(create_simple_fuzzable_request(1))

        def queue_get_after_delay(queue):
            time.sleep(1)
            queue.get()
            queue.task_done()

        t = threading.Thread(target=queue_get_after_delay,
                             args=(q,))
        t.start()

        start = time.time()

        # This should take 1 second
        q.join()

        spent = time.time() - start

        self.assertGreater(spent, 1)