def mainMultiProcess(): global task_type config = utils.get_config() while True: all_tasks = tasks.splitTasks(tasks.get(task_type), config['slice_step']) if all_tasks != []: p = ProcessPoolExecutor(config['worker']) for t in all_tasks: p.submit(processor, t) p.shutdown() time.sleep(3)
def main(): global task_type while True: all_tasks = tasks.get(task_type) loop_tasks = [] if all_tasks != []: loop = asyncio.get_event_loop() for one_task in all_tasks: user_task = UserProcess(loop, task_type) loop_tasks.append( asyncio.ensure_future(user_task.doMultiTasks(one_task))) loop.run_until_complete(asyncio.wait(loop_tasks)) loop.close() time.sleep(3)