Skip to content

perf: Use asyncio.gather for concurrent API fetches in briefing and tonight modules #6

@Orinks

Description

@Orinks

Problem

Both DailyBriefing.get_briefing() and TonightSummary.get_tonight() fetch data from 6-7 independent APIs sequentially. Each API call has a 15s timeout, so worst case is ~100s of serial waiting.

Solution

Use asyncio.gather(return_exceptions=True) to fetch all independent data sources concurrently. This reduces total latency from the sum of all calls to the duration of the slowest one.

Impact

  • Typical briefing generation drops from ~3-5s to ~1s (assuming all APIs respond)
  • Worst-case timeout drops from ~100s to ~15s
  • No behavior changes; errors still handled gracefully per-source

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions