Reuse a persistent aiohttp.ClientSession in GiphyService
#26
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#26
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
services/giphy_service.py:189and:248— Both GIF methods create a newaiohttp.ClientSessionper invocation. Creating and tearing down a session on every call has measurable overhead (DNS resolution, TCP handshake). The service already has__init__-based state; a session could be stored and reused.File Locations
services/giphy_service.py:189services/giphy_service.py:248Labels
performance, tech-debt
Priority
low
Opened PR #66 to fix this.
Added
self._sessiontoGiphyService.__init__and a_get_session()lazy initialiser that creates (or recreates if closed) a singleaiohttp.ClientSession. Bothget_disappointment_gifandget_gifnow callself._get_session()instead of creating a new session per invocation.