Maison > Questions et réponses > le corps du texte
代码如下:
def print_result(request,result):
if result["success"] == True:
write_file(filename,content)
else:
pass
def multi_exec(targets,thread_num):
pool = threadpool.ThreadPool(thread_num)
args = [target for target in targets]
reqs = threadpool.makeRequests(fun,args,print_result)
[pool.putRequest(req) for req in reqs]
pool.wait()
在打印结果的函数:print_result中,需要将结果保存到文件中,请问,这里是否需要加锁操作?