Skip to content

Commit

Permalink
the prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed Oct 28, 2022
1 parent 12f56d7 commit f03f064
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def connection_lost(self, exc: Optional[BaseException]) -> None:

super().connection_lost(exc)

should_cancel_task_handler = self._manager.cancel_when_connection_lost

self._manager = None
self._force_close = True
self._request_factory = None
Expand All @@ -330,6 +332,9 @@ def connection_lost(self, exc: Optional[BaseException]) -> None:
if self._waiter is not None:
self._waiter.cancel()

if should_cancel_task_handler and self._task_handler is not None:
self._task_handler.cancel()

self._task_handler = None

if self._payload_parser is not None:
Expand Down
2 changes: 2 additions & 0 deletions aiohttp/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(
*,
request_factory: Optional[_RequestFactory] = None,
debug: Optional[bool] = None,
cancel_when_connection_lost: bool = False,
**kwargs: Any,
) -> None:
if debug is not None:
Expand All @@ -33,6 +34,7 @@ def __init__(
self.requests_count = 0
self.request_handler = handler
self.request_factory = request_factory or self._make_request
self.cancel_when_connection_lost = cancel_when_connection_lost

@property
def connections(self) -> List[RequestHandler]:
Expand Down

0 comments on commit f03f064

Please sign in to comment.