Example #1
0
    def test_initial_running_strategy_with_parallel(self,
                                                    process_pool: SimplePool):
        process_pool._initial_running_strategy()

        from multirunnable.pool import Pool_Runnable_Strategy
        assert Pool_Runnable_Strategy is not None, "It should be assign running-strategy instance."
        assert isinstance(
            Pool_Runnable_Strategy, ProcessPoolStrategy
        ), "It should be an sub-instance of 'ProcessPoolStrategy'."
Example #2
0
    def test_initial_running_strategy_with_coroutine(
            self, green_thread_pool: SimplePool):
        green_thread_pool._initial_running_strategy()

        from multirunnable.pool import Pool_Runnable_Strategy
        assert Pool_Runnable_Strategy is not None, "It should be assign running-strategy instance."
        assert isinstance(
            Pool_Runnable_Strategy, GreenThreadPoolStrategy
        ), "It should be an sub-instance of 'GreenThreadPoolStrategy'."
Example #3
0
    def test_initial_running_strategy(self, simple_pool: SimplePool):
        simple_pool._initial_running_strategy()

        _rmode = get_current_mode(force=True)

        from multirunnable.pool import Pool_Runnable_Strategy
        if _rmode is RunningMode.Parallel:
            assert Pool_Runnable_Strategy is not None, "It should be assign running-strategy instance."
            assert isinstance(
                Pool_Runnable_Strategy, ProcessPoolStrategy
            ), "It should be an sub-instance of 'ProcessPoolStrategy'."
        elif _rmode is RunningMode.Concurrent:
            assert Pool_Runnable_Strategy is not None, "It should be assign running-strategy instance."
            assert isinstance(
                Pool_Runnable_Strategy, ThreadPoolStrategy
            ), "It should be an sub-instance of 'ThreadPoolStrategy'."
        elif _rmode is RunningMode.GreenThread:
            assert Pool_Runnable_Strategy is not None, "It should be assign running-strategy instance."
            assert isinstance(
                Pool_Runnable_Strategy, GreenThreadPoolStrategy
            ), "It should be an sub-instance of 'GreenThreadPoolStrategy'."
        else:
            raise ValueError("The RunningMode has the unexpected mode.")