Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa909094 authored by Jeongik Cha's avatar Jeongik Cha
Browse files

parallelize add_partition_calls only if output_zip is None

if output_zip isn't None, writing into zip file in parallel is not
thread-safe.

Bug: 281960217
Test: m dist
Change-Id: I10d68a4bb779cee244f40410ec95d38ca6040306
parent 03d014a0
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -1083,7 +1083,12 @@ def AddImagesToTargetFiles(filename):
      ("system_dlkm", has_system_dlkm, AddSystemDlkm, []),
      ("system_other", has_system_other, AddSystemOther, []),
  )

  # If output_zip exists, each add_partition_calls writes bytes to the same output_zip,
  # which is not thread-safe. So, run them in serial if output_zip exists.
  if output_zip:
    for call in add_partition_calls:
      add_partition(*call)
  else:
    with ThreadPoolExecutor(max_workers=len(add_partition_calls)) as executor:
      for future in [executor.submit(add_partition, *call) for call in add_partition_calls]:
        future.result()