From cbe19ea6066a600cbd0b5110db5d43f8252d14a8 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 13 六月 2024 11:23:53 +0800 Subject: [PATCH] L撤成交进度相关改进 --- test/test_threadpool.py | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/test_threadpool.py b/test/test_threadpool.py index 1a0d853..ebb7beb 100644 --- a/test/test_threadpool.py +++ b/test/test_threadpool.py @@ -58,12 +58,21 @@ 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) + +if __name__ == '__main__': + thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=20) + thread_pool.submit(lambda: test1("123123")) + thread_pool.submit(lambda: test1("123123")) + thread_pool.submit(lambda: test1("123123")) + thread_pool.submit(lambda: test1("123123")) while True: - time.sleep(2) + running_count = 0 + for future in thread_pool._threads: + if future.is_alive(): + running_count += 1 + print(running_count) + time.sleep(1) -- Gitblit v1.8.0