Skip to content

Commit

Permalink
Use CancelScope instead of move_on_after in request.is_disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
uSpike committed May 27, 2021
1 parent 4e43146 commit a1ceb35
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion starlette/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ async def is_disconnected(self) -> bool:
if not self._is_disconnected:
message: Message = {}

with anyio.move_on_after(0):
# If message isn't immediately available, move on
with anyio.CancelScope() as cs:
cs.cancel()
message = await self._receive()

if message.get("type") == "http.disconnect":
Expand Down

0 comments on commit a1ceb35

Please sign in to comment.