Skip to content

Commit

Permalink
Remove Request.wait_for_disconnection() method (#8636)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Aug 8, 2024
1 parent e494277 commit 51d872e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGES/8636.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed ``Request.wait_for_disconnection()`` which was mistakenly added briefly in 3.10.0 -- by :user:`Dreamsorcerer`.
24 changes: 2 additions & 22 deletions aiohttp/web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
MutableMapping,
Optional,
Pattern,
Set,
Tuple,
Union,
cast,
Expand All @@ -43,7 +42,6 @@
reify,
sentinel,
set_exception,
set_result,
)
from .http_parser import RawRequestMessage
from .http_writer import HttpVersion
Expand Down Expand Up @@ -141,7 +139,6 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
"_loop",
"_transport_sslcontext",
"_transport_peername",
"_disconnection_waiters",
"__weakref__",
)

Expand Down Expand Up @@ -190,7 +187,6 @@ def __init__(
self._task = task
self._client_max_size = client_max_size
self._loop = loop
self._disconnection_waiters: Set[asyncio.Future[None]] = set()

transport = self._protocol.transport
assert transport is not None
Expand Down Expand Up @@ -817,13 +813,8 @@ async def _prepare_hook(self, response: StreamResponse) -> None:

def _cancel(self, exc: BaseException) -> None:
set_exception(self._payload, exc)
for fut in self._disconnection_waiters:
set_result(fut, None)

def _finish(self) -> None:
for fut in self._disconnection_waiters:
fut.cancel()

if self._post is None or self.content_type != "multipart/form-data":
return

Expand All @@ -832,19 +823,8 @@ def _finish(self) -> None:
# NOTE: instances of files sent within multipart request body
# NOTE: via HTTP POST request.
for file_name, file_field_object in self._post.items():
if not isinstance(file_field_object, FileField):
continue

file_field_object.file.close()

async def wait_for_disconnection(self) -> None:
loop = asyncio.get_event_loop()
fut: asyncio.Future[None] = loop.create_future()
self._disconnection_waiters.add(fut)
try:
await fut
finally:
self._disconnection_waiters.remove(fut)
if isinstance(file_field_object, FileField):
file_field_object.file.close()


class Request(BaseRequest):
Expand Down
14 changes: 0 additions & 14 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -490,20 +490,6 @@ and :ref:`aiohttp-web-signals` handlers.
required work will be processed by :mod:`aiohttp.web`
internal machinery.

.. method:: wait_for_disconnection()
:async:

Returns when the connection that sent this request closes

If there is no client disconnection during request handling, this
coroutine gets cancelled automatically at the end of this request being
handled.

This can be used in handlers as a means of receiving a notification of
premature client disconnection.

.. versionadded:: 4.0

.. class:: Request

A request used for receiving request's information by *web handler*.
Expand Down

0 comments on commit 51d872e

Please sign in to comment.