|
16 | 16 | import string |
17 | 17 | import tempfile |
18 | 18 | import json |
| 19 | +from multiprocessing.pool import ThreadPool |
19 | 20 |
|
20 | 21 | secret_url = os.path.expandvars("$SECRET_URL").strip().rstrip("/") |
21 | 22 | secret_key = os.path.expandvars("$SECRET_KEY") |
@@ -54,6 +55,14 @@ def run_process( |
54 | 55 | return result |
55 | 56 |
|
56 | 57 |
|
| 58 | +def run_process_async( |
| 59 | + *cmd: str, |
| 60 | + env: Optional[Mapping[str, str]] = None, |
| 61 | + cwd: Optional[str] = None, |
| 62 | +): |
| 63 | + return subprocess.Popen(cmd, env=env, cwd=cwd, stdout=PIPE, stderr=PIPE) |
| 64 | + |
| 65 | + |
57 | 66 | def rand_str(len: int, seed: Any = None): |
58 | 67 | old_state: object = None |
59 | 68 | if seed is not None: |
@@ -272,7 +281,7 @@ def codesign_async(identity: str, component: Path, entitlements: Optional[Path] |
272 | 281 | cmd = ["codesign", "--continue", "-f", "--no-strict", "-s", identity] |
273 | 282 | if entitlements: |
274 | 283 | cmd.extend(["--entitlements", str(entitlements)]) |
275 | | - return subprocess.Popen([*cmd, str(component)], stdout=PIPE, stderr=PIPE) |
| 284 | + return run_process_async(*cmd, str(component)) |
276 | 285 |
|
277 | 286 |
|
278 | 287 | def clean_dev_portal_name(name: str): |
@@ -342,19 +351,28 @@ def fastlane_register_app_extras( |
342 | 351 | id if id.startswith(extra_prefix) else extra_prefix + id[id.index(".") + 1 :] for id in matched_ids |
343 | 352 | ) |
344 | 353 |
|
| 354 | + jobs: List[Popen[bytes]] = [] |
| 355 | + |
345 | 356 | for id in matched_ids: |
346 | | - run_process( |
347 | | - "fastlane", |
348 | | - "produce", |
349 | | - extra_type, |
350 | | - "--skip_itc", |
351 | | - "-g", |
352 | | - id, |
353 | | - "-n", |
354 | | - clean_dev_portal_name(f"ST {id}"), |
355 | | - env=my_env, |
| 357 | + jobs.append( |
| 358 | + run_process_async( |
| 359 | + "fastlane", |
| 360 | + "produce", |
| 361 | + extra_type, |
| 362 | + "--skip_itc", |
| 363 | + "-g", |
| 364 | + id, |
| 365 | + "-n", |
| 366 | + clean_dev_portal_name(f"ST {id}"), |
| 367 | + env=my_env, |
| 368 | + ) |
356 | 369 | ) |
357 | 370 |
|
| 371 | + for pipe in jobs: |
| 372 | + if pipe.poll() is None: |
| 373 | + pipe.wait() |
| 374 | + popen_check(pipe) |
| 375 | + |
358 | 376 | run_process( |
359 | 377 | "fastlane", |
360 | 378 | "produce", |
@@ -464,8 +482,14 @@ def fastlane_register_app( |
464 | 482 | env=my_env, |
465 | 483 | ) |
466 | 484 |
|
467 | | - fastlane_register_app_extras(my_env, bundle_id, "cloud_container", "iCloud.", icloud_entitlements, entitlements) |
468 | | - fastlane_register_app_extras(my_env, bundle_id, "group", "group.", group_entitlements, entitlements) |
| 485 | + app_extras = [("cloud_container", "iCloud."), ("group", "group.")] |
| 486 | + with ThreadPool(len(app_extras)) as p: |
| 487 | + p.starmap( |
| 488 | + lambda extra_type, extra_prefix: fastlane_register_app_extras( |
| 489 | + my_env, bundle_id, extra_type, extra_prefix, icloud_entitlements, entitlements |
| 490 | + ), |
| 491 | + app_extras, |
| 492 | + ) |
469 | 493 |
|
470 | 494 |
|
471 | 495 | def fastlane_get_prov_profile( |
|
0 commit comments