def CoroutineWithGreenThread(_functions: List): set_mode(mode=RunningMode.GreenThread) _strategy_adapter = ExecutorStrategyAdapter(mode=RunningMode.GreenThread, executors=_Worker_Size) _strategy = _strategy_adapter.get_simple() MapByStrategy._map_with_multiple_workers(_strategy, _functions)
def Concurrent(_functions: List): set_mode(mode=RunningMode.Concurrent) _strategy_adapter = ExecutorStrategyAdapter(mode=RunningMode.Concurrent, executors=_Worker_Size) _strategy = _strategy_adapter.get_simple() MapByStrategy._map_with_multiple_workers(_strategy, _functions)
def Parallel(_function): set_mode(mode=RunningMode.Parallel) _strategy_adapter = ExecutorStrategyAdapter(mode=RunningMode.Parallel, executors=_Worker_Size) _strategy = _strategy_adapter.get_simple() RunByStrategy._run_with_multiple_workers(_strategy, _function)
def CoroutineWithAsynchronous(_function, event_loop=None, _feature=None): set_mode(mode=RunningMode.Asynchronous) _strategy_adapter = ExecutorStrategyAdapter(mode=RunningMode.Asynchronous, executors=_Worker_Size) _strategy = _strategy_adapter.get_simple() async def __process(): await _strategy.initialization(queue_tasks=None, features=_feature, event_loop=event_loop) _ps = [_strategy.generate_worker(_function) for _ in range(_Worker_Size)] await _strategy.activate_workers(_ps) if (PYTHON_MAJOR_VERSION, PYTHON_MINOR_VERSION) > (3, 6): asyncio.run(__process()) else: _event_loop = asyncio.get_event_loop() _event_loop.run_until_complete(__process())
def CoroutineWithAsynchronous(_functions: List, _feature=None): set_mode(mode=RunningMode.Asynchronous) _strategy_adapter = ExecutorStrategyAdapter(mode=RunningMode.Asynchronous, executors=_Worker_Size) _strategy = _strategy_adapter.get_simple() _strategy.map_with_function(functions=_functions, features=_feature)