From 165042052bbc089787eba9fb71f72659135a34e9 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 14 九月 2023 11:17:56 +0800 Subject: [PATCH] 下单采用线程池 --- test/test_threadpool.py | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_threadpool.py b/test/test_threadpool.py index 1a0d853..3a58646 100644 --- a/test/test_threadpool.py +++ b/test/test_threadpool.py @@ -58,12 +58,12 @@ time.sleep(2) -if __name__ == '__main__': - p1, p2 = multiprocessing.Pipe() - serverProcess = multiprocessing.Process(target=run_process_1, args=(p1,)) - jueJinProcess = multiprocessing.Process(target=run_process_2, args=(p2,)) - serverProcess.start() - jueJinProcess.start() +def test1(params): + time.sleep(1) + print("鎵ц缁撴潫", params) - while True: - time.sleep(2) + +if __name__ == '__main__': + thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=20) + thread_pool.submit(lambda: test1("123123")) + input() -- Gitblit v1.8.0