Skip to content

Commit

Permalink
🐛 fix warning about coroutine method 'aclose' of 'AsyncSession.resolv…
Browse files Browse the repository at this point in the history
…e_redirects' was never awaited (#181)

3.11.0 (2024-11-20)
-------------------

**Added**
- base_url parameter to `niquests.Session` or `niquests.AsyncSession`.
automatically prefix every request emitted with it. (#179)

**Fixed**
- warning about coroutine method 'aclose' of
'AsyncSession.resolve_redirects' was never awaited.
  • Loading branch information
Ousret authored Nov 20, 2024
1 parent ce15eb6 commit dd70717
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release History
===============

3.11.0 (2024-11-20)
-------------------

**Added**
- base_url parameter to `niquests.Session` or `niquests.AsyncSession`. automatically prefix every request emitted with it. (#179)

**Fixed**
- warning about coroutine method 'aclose' of 'AsyncSession.resolve_redirects' was never awaited.

3.10.3 (2024-11-13)
------------------

Expand Down
14 changes: 8 additions & 6 deletions src/niquests/_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,13 @@ async def on_early_response(early_response: Response) -> None:
if r.lazy is True:

async def _redirect_method_ref(x, y):
aiter_gen = self.resolve_redirects(x, y, yield_requests=True, **kwargs)
try:
return await self.resolve_redirects(
x, y, yield_requests=True, **kwargs
).__anext__()
return await aiter_gen.__anext__()
except StopAsyncIteration:
return None
finally:
await aiter_gen.aclose()

r._resolve_redirect = _redirect_method_ref

Expand Down Expand Up @@ -567,13 +568,14 @@ async def _redirect_method_ref(x, y):
# If redirects aren't being followed, store the response on the Request for Response.next().
if not allow_redirects:
if r.is_redirect:
gen = self.resolve_redirects(r, request, yield_requests=True, **kwargs)

try:
gen = self.resolve_redirects(
r, request, yield_requests=True, **kwargs
)
r._next = await gen.__anext__() # type: ignore[assignment]
except StopAsyncIteration:
pass
finally:
await gen.aclose()

if not stream:
if isinstance(r, AsyncResponse):
Expand Down

0 comments on commit dd70717

Please sign in to comment.