-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben Thomas
committed
Feb 11, 2025
1 parent
23fce9e
commit 4fdd301
Showing
7 changed files
with
44 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) Microsoft. All rights reserved. | ||
import aiohttp | ||
|
||
|
||
class AsyncSession: | ||
"""A wrapper around aiohttp.ClientSession that can be used as an async context manager.""" | ||
|
||
def __init__(self, session: aiohttp.ClientSession = None): | ||
"""Initializes a new instance of the AsyncSession class.""" | ||
self._session = session if session else aiohttp.ClientSession() | ||
|
||
async def __aenter__(self): | ||
"""Enter the session.""" | ||
return await self._session.__aenter__() | ||
|
||
async def __aexit__(self, *args, **kwargs): | ||
"""Close the session.""" | ||
await self._session.close() |