Merge pull request #2074 from ei-grad/no-pool-for-single-thread

remote: don't use threadpool for single thread
This commit is contained in:
Ruslan Kuprieiev
2019-05-30 19:07:32 +03:00
committed by GitHub
+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)