remote: don't use threadpool for single thread

This commit is contained in:
Andrew Grigorev
2019-05-30 18:27:00 +03:00
parent 8df0712b06
commit a1d3013596
+13 -7
View File
@@ -464,14 +464,20 @@ class RemoteLOCAL(RemoteBASE):
if len(chunks) == 0:
return 0
futures = []
with ThreadPoolExecutor(max_workers=jobs) as executor:
for from_infos, to_infos, names in chunks:
res = executor.submit(func, from_infos, to_infos, names=names)
futures.append(res)
if jobs > 1:
futures = []
with ThreadPoolExecutor(max_workers=jobs) as executor:
for from_infos, to_infos, names in chunks:
res = executor.submit(
func, from_infos, to_infos, names=names
)
futures.append(res)
for f in futures:
f.result()
for f in futures:
f.result()
else:
for from_infos, to_infos, names in chunks:
func(from_infos, to_infos, names=names)
return len(chunks)