コード例 #1
0
ファイル: test_pool.py プロジェクト: marik332000/tinys3
    def test_all_completed_class_method(self):
        """
        Test the 'all_completed' class method
        """
        responses = []

        for i in range(10):
            responses.append(AsyncResponse())

        # Create a method that will be executed on a different thread
        # And resolve each async response
        def resolver():
            time.sleep(1)
            for i in responses:
                i.resolve(TEST_RESPONSE)

        # Start the resolving thread
        threading.Thread(target=resolver).start()

        results = AsyncResponse.all_completed(responses)

        self.assertEquals(len(results), len(responses))

        for i in results:
            self.assertEquals(i, TEST_RESPONSE)
コード例 #2
0
    def test_all_completed_class_method(self):
        """
        Test the 'all_completed' class method
        """
        responses = []

        for i in range(10):
            responses.append(AsyncResponse())

        # Create a method that will be executed on a different thread
        # And resolve each async response
        def resolver():
            time.sleep(1)
            for i in responses:
                i.resolve(TEST_RESPONSE)

        # Start the resolving thread
        threading.Thread(target=resolver).start()

        results = AsyncResponse.all_completed(responses)

        self.assertEquals(len(results), len(responses))

        for i in results:
            self.assertEquals(i, TEST_RESPONSE)
コード例 #3
0
ファイル: test_pool.py プロジェクト: marik332000/tinys3
    def test_all_completed_with_timeout(self):
        """
        Test the 'all_completed' class method
        """
        responses = []

        for i in range(10):
            responses.append(AsyncResponse())

        # Create a method that will be executed on a different thread
        # And resolve each async response
        def resolver():
            time.sleep(10)
            for i in responses:
                i.resolve(TEST_RESPONSE)

        # Start the resolving thread
        t = threading.Thread(target=resolver)
        t.daemon = True
        t.start()

        results = AsyncResponse.all_completed(responses, timeout=1)
コード例 #4
0
    def test_all_completed_with_timeout(self):
        """
        Test the 'all_completed' class method
        """
        responses = []

        for i in range(10):
            responses.append(AsyncResponse())

        # Create a method that will be executed on a different thread
        # And resolve each async response
        def resolver():
            time.sleep(10)
            for i in responses:
                i.resolve(TEST_RESPONSE)

        # Start the resolving thread
        t = threading.Thread(target=resolver)
        t.daemon = True
        t.start()

        results = AsyncResponse.all_completed(responses, timeout=1)