Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions stealth_requests/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ class AsyncStealthSession(BaseStealthSession, AsyncSession):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

async def __aenter__(self):
aenter = getattr(super(), '__aenter__', None)
if aenter is not None:
return await aenter()
return self

async def __aexit__(self, exc_type, exc, tb):
aexit = getattr(super(), '__aexit__', None)
if aexit is not None:
return await aexit(exc_type, exc, tb)

aclose = getattr(self, 'aclose', None)
if aclose is not None:
await aclose()
else:
self.close()

return False

async def request(self, method: HttpMethod, url: str, *args, retry: int = 0, **kwargs) -> StealthResponse:
assert retry >= 0

Expand Down