From 8ddd58101c475c9e94b12b3923e5820af64ecaf5 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Wed, 8 Apr 2026 01:02:10 -0500 Subject: [PATCH] perf: parallelize scout opportunity creation and remove sleep(2) (#101) Closes #101 Replace sequential for-loop with asyncio.gather() so all scout opportunities are created concurrently. Remove asyncio.sleep(2) that added ~8s of post-display delay for multi-pack opens. create_scout_opportunity() already guards against empty pack_cards with an early return. Co-Authored-By: Claude Sonnet 4.6 --- helpers/main.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/helpers/main.py b/helpers/main.py index 2cae635..fe59c73 100644 --- a/helpers/main.py +++ b/helpers/main.py @@ -1786,14 +1786,18 @@ async def open_st_pr_packs(all_packs: list, team: dict, context): pack_type_name = all_packs[0].get("pack_type", {}).get("name") if pack_type_name in SCOUTABLE_PACK_TYPES: - for p_id in pack_ids: - pack_cards = [c for c in all_cards if c.get("pack_id") == p_id] - if pack_cards: - await create_scout_opportunity( - pack_cards, team, pack_channel, author, context + await asyncio.gather( + *[ + create_scout_opportunity( + [c for c in all_cards if c.get("pack_id") == p_id], + team, + pack_channel, + author, + context, ) - if len(pack_ids) > 1: - await asyncio.sleep(2) + for p_id in pack_ids + ] + ) async def get_choice_from_cards(