
def thread_function(): logging.info("Thread %s: starting") time.sleep(2) logging.info("Thread %s: finishing") with concurrent.futures.ThreadPoolExecutor(3) as executor: executor.map(thread_function) 如果 thread_function 没有参数的话,executor.map 是不是应该没有第二个参数.
1 leon0318 2019-12-10 09:33:46 +08:00 |
3 lbfeng OP 关于 threadpoolexecutor map parameter 的都是 multiple parameter 的问题,没有 no parameter。。。 |
4 ClericPy 2019-12-10 11:30:42 +08:00 该看的是 submit 得到 Future 后的用法吧 map 又不是万能的, 实在无聊那就 xx.map(lambda f: f(), [f]) |
5 guokeke 2019-12-10 11:35:07 +08:00 是 |
6 wzwwzw 2019-12-10 12:45:20 +08:00 用 submit / |
7 lbfeng OP ``` with concurrent.futures.ThreadPoolExecutor(3) as executor: future = executor.submit(thread_function_no_parameter) print(future.result()) ``` 如果想启动 3 个 thread,需要重复 executor.submit(thread_function_no_parameter) 3 遍?? |