We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Cancel tasks with a message where appropriate
[cancel()](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel) also accepts a "msg" argument, might it be a good idea for this "message" to be added to places like https://github.com/sanic-org/sanic/blob/f7abf3db1bd4e79cd5121327359fc9021fab7ff3/sanic/server/protocols/http_protocol.py#L172 that are otherwise calling cancel() with no explanatory message?    if this is the CancelledError this user is getting, a simple message there would save everyone a lot of time.

_Originally posted by @zzzeek in https://github.com/sanic-org/sanic/issues/2296#issuecomment-983881945_

---

Where we are able to in Py3.9, we should add a message to `cancel()`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sanic/server/protocols/http_protocol.py`
Content:
```
1 from __future__ import annotations
2 
3 from typing import TYPE_CHECKING, Optional
4 
5 from sanic.touchup.meta import TouchUpMeta
6 
7 
8 if TYPE_CHECKING:  # no cov
9     from sanic.app import Sanic
10 
11 from asyncio import CancelledError
12 from time import monotonic as current_time
13 
14 from sanic.exceptions import RequestTimeout, ServiceUnavailable
15 from sanic.http import Http, Stage
16 from sanic.log import error_logger, logger
17 from sanic.models.server_types import ConnInfo
18 from sanic.request import Request
19 from sanic.server.protocols.base_protocol import SanicProtocol
20 
21 
22 class HttpProtocol(SanicProtocol, metaclass=TouchUpMeta):
23     """
24     This class provides implements the HTTP 1.1 protocol on top of our
25     Sanic Server transport
26     """
27 
28     __touchup__ = (
29         "send",
30         "connection_task",
31     )
32     __slots__ = (
33         # request params
34         "request",
35         # request config
36         "request_handler",
37         "request_timeout",
38         "response_timeout",
39         "keep_alive_timeout",
40         "request_max_size",
41         "request_class",
42         "error_handler",
43         # enable or disable access log purpose
44         "access_log",
45         # connection management
46         "state",
47         "url",
48         "_handler_task",
49         "_http",
50         "_exception",
51         "recv_buffer",
52     )
53 
54     def __init__(
55         self,
56         *,
57         loop,
58         app: Sanic,
59         signal=None,
60         connections=None,
61         state=None,
62         unix=None,
63         **kwargs,
64     ):
65         super().__init__(
66             loop=loop,
67             app=app,
68             signal=signal,
69             connections=connections,
70             unix=unix,
71         )
72         self.url = None
73         self.request: Optional[Request] = None
74         self.access_log = self.app.config.ACCESS_LOG
75         self.request_handler = self.app.handle_request
76         self.error_handler = self.app.error_handler
77         self.request_timeout = self.app.config.REQUEST_TIMEOUT
78         self.response_timeout = self.app.config.RESPONSE_TIMEOUT
79         self.keep_alive_timeout = self.app.config.KEEP_ALIVE_TIMEOUT
80         self.request_max_size = self.app.config.REQUEST_MAX_SIZE
81         self.request_class = self.app.request_class or Request
82         self.state = state if state else {}
83         if "requests_count" not in self.state:
84             self.state["requests_count"] = 0
85         self._exception = None
86 
87     def _setup_connection(self):
88         self._http = Http(self)
89         self._time = current_time()
90         self.check_timeouts()
91 
92     async def connection_task(self):  # no cov
93         """
94         Run a HTTP connection.
95 
96         Timeouts and some additional error handling occur here, while most of
97         everything else happens in class Http or in code called from there.
98         """
99         try:
100             self._setup_connection()
101             await self.app.dispatch(
102                 "http.lifecycle.begin",
103                 inline=True,
104                 context={"conn_info": self.conn_info},
105             )
106             await self._http.http1()
107         except CancelledError:
108             pass
109         except Exception:
110             error_logger.exception("protocol.connection_task uncaught")
111         finally:
112             if (
113                 self.app.debug
114                 and self._http
115                 and self.transport
116                 and not self._http.upgrade_websocket
117             ):
118                 ip = self.transport.get_extra_info("peername")
119                 error_logger.error(
120                     "Connection lost before response written"
121                     f" @ {ip} {self._http.request}"
122                 )
123             self._http = None
124             self._task = None
125             try:
126                 self.close()
127             except BaseException:
128                 error_logger.exception("Closing failed")
129             finally:
130                 await self.app.dispatch(
131                     "http.lifecycle.complete",
132                     inline=True,
133                     context={"conn_info": self.conn_info},
134                 )
135                 # Important to keep this Ellipsis here for the TouchUp module
136                 ...
137 
138     def check_timeouts(self):
139         """
140         Runs itself periodically to enforce any expired timeouts.
141         """
142         try:
143             if not self._task:
144                 return
145             duration = current_time() - self._time
146             stage = self._http.stage
147             if stage is Stage.IDLE and duration > self.keep_alive_timeout:
148                 logger.debug("KeepAlive Timeout. Closing connection.")
149             elif stage is Stage.REQUEST and duration > self.request_timeout:
150                 logger.debug("Request Timeout. Closing connection.")
151                 self._http.exception = RequestTimeout("Request Timeout")
152             elif stage is Stage.HANDLER and self._http.upgrade_websocket:
153                 logger.debug("Handling websocket. Timeouts disabled.")
154                 return
155             elif (
156                 stage in (Stage.HANDLER, Stage.RESPONSE, Stage.FAILED)
157                 and duration > self.response_timeout
158             ):
159                 logger.debug("Response Timeout. Closing connection.")
160                 self._http.exception = ServiceUnavailable("Response Timeout")
161             else:
162                 interval = (
163                     min(
164                         self.keep_alive_timeout,
165                         self.request_timeout,
166                         self.response_timeout,
167                     )
168                     / 2
169                 )
170                 self.loop.call_later(max(0.1, interval), self.check_timeouts)
171                 return
172             self._task.cancel()
173         except Exception:
174             error_logger.exception("protocol.check_timeouts")
175 
176     async def send(self, data):  # no cov
177         """
178         Writes HTTP data with backpressure control.
179         """
180         await self._can_write.wait()
181         if self.transport.is_closing():
182             raise CancelledError
183         await self.app.dispatch(
184             "http.lifecycle.send",
185             inline=True,
186             context={"data": data},
187         )
188         self.transport.write(data)
189         self._time = current_time()
190 
191     def close_if_idle(self) -> bool:
192         """
193         Close the connection if a request is not being sent or received
194 
195         :return: boolean - True if closed, false if staying open
196         """
197         if self._http is None or self._http.stage is Stage.IDLE:
198             self.close()
199             return True
200         return False
201 
202     # -------------------------------------------- #
203     # Only asyncio.Protocol callbacks below this
204     # -------------------------------------------- #
205 
206     def connection_made(self, transport):
207         """
208         HTTP-protocol-specific new connection handler
209         """
210         try:
211             # TODO: Benchmark to find suitable write buffer limits
212             transport.set_write_buffer_limits(low=16384, high=65536)
213             self.connections.add(self)
214             self.transport = transport
215             self._task = self.loop.create_task(self.connection_task())
216             self.recv_buffer = bytearray()
217             self.conn_info = ConnInfo(self.transport, unix=self._unix)
218         except Exception:
219             error_logger.exception("protocol.connect_made")
220 
221     def data_received(self, data: bytes):
222 
223         try:
224             self._time = current_time()
225             if not data:
226                 return self.close()
227             self.recv_buffer += data
228 
229             if (
230                 len(self.recv_buffer) >= self.app.config.REQUEST_BUFFER_SIZE
231                 and self.transport
232             ):
233                 self.transport.pause_reading()
234 
235             if self._data_received:
236                 self._data_received.set()
237         except Exception:
238             error_logger.exception("protocol.data_received")
239
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sanic/server/protocols/http_protocol.py b/sanic/server/protocols/http_protocol.py
--- a/sanic/server/protocols/http_protocol.py
+++ b/sanic/server/protocols/http_protocol.py
@@ -8,6 +8,8 @@
 if TYPE_CHECKING:  # no cov
     from sanic.app import Sanic
 
+import sys
+
 from asyncio import CancelledError
 from time import monotonic as current_time
 
@@ -169,7 +171,10 @@
                 )
                 self.loop.call_later(max(0.1, interval), self.check_timeouts)
                 return
-            self._task.cancel()
+            cancel_msg_args = ()
+            if sys.version_info >= (3, 9):
+                cancel_msg_args = ("Cancel connection task with a timeout",)
+            self._task.cancel(*cancel_msg_args)
         except Exception:
             error_logger.exception("protocol.check_timeouts")

{"golden_diff": "diff --git a/sanic/server/protocols/http_protocol.py b/sanic/server/protocols/http_protocol.py\n--- a/sanic/server/protocols/http_protocol.py\n+++ b/sanic/server/protocols/http_protocol.py\n@@ -8,6 +8,8 @@\n if TYPE_CHECKING:  # no cov\n     from sanic.app import Sanic\n \n+import sys\n+\n from asyncio import CancelledError\n from time import monotonic as current_time\n \n@@ -169,7 +171,10 @@\n                 )\n                 self.loop.call_later(max(0.1, interval), self.check_timeouts)\n                 return\n-            self._task.cancel()\n+            cancel_msg_args = ()\n+            if sys.version_info >= (3, 9):\n+                cancel_msg_args = (\"Cancel connection task with a timeout\",)\n+            self._task.cancel(*cancel_msg_args)\n         except Exception:\n             error_logger.exception(\"protocol.check_timeouts\")\n", "issue": "Cancel tasks with a message where appropriate\n[cancel()](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel) also accepts a \"msg\" argument, might it be a good idea for this \"message\" to be added to places like https://github.com/sanic-org/sanic/blob/f7abf3db1bd4e79cd5121327359fc9021fab7ff3/sanic/server/protocols/http_protocol.py#L172 that are otherwise calling cancel() with no explanatory message?    if this is the CancelledError this user is getting, a simple message there would save everyone a lot of time.\r\n\r\n_Originally posted by @zzzeek in https://github.com/sanic-org/sanic/issues/2296#issuecomment-983881945_\r\n\r\n---\r\n\r\nWhere we are able to in Py3.9, we should add a message to `cancel()`.\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING, Optional\n\nfrom sanic.touchup.meta import TouchUpMeta\n\n\nif TYPE_CHECKING:  # no cov\n    from sanic.app import Sanic\n\nfrom asyncio import CancelledError\nfrom time import monotonic as current_time\n\nfrom sanic.exceptions import RequestTimeout, ServiceUnavailable\nfrom sanic.http import Http, Stage\nfrom sanic.log import error_logger, logger\nfrom sanic.models.server_types import ConnInfo\nfrom sanic.request import Request\nfrom sanic.server.protocols.base_protocol import SanicProtocol\n\n\nclass HttpProtocol(SanicProtocol, metaclass=TouchUpMeta):\n    \"\"\"\n    This class provides implements the HTTP 1.1 protocol on top of our\n    Sanic Server transport\n    \"\"\"\n\n    __touchup__ = (\n        \"send\",\n        \"connection_task\",\n    )\n    __slots__ = (\n        # request params\n        \"request\",\n        # request config\n        \"request_handler\",\n        \"request_timeout\",\n        \"response_timeout\",\n        \"keep_alive_timeout\",\n        \"request_max_size\",\n        \"request_class\",\n        \"error_handler\",\n        # enable or disable access log purpose\n        \"access_log\",\n        # connection management\n        \"state\",\n        \"url\",\n        \"_handler_task\",\n        \"_http\",\n        \"_exception\",\n        \"recv_buffer\",\n    )\n\n    def __init__(\n        self,\n        *,\n        loop,\n        app: Sanic,\n        signal=None,\n        connections=None,\n        state=None,\n        unix=None,\n        **kwargs,\n    ):\n        super().__init__(\n            loop=loop,\n            app=app,\n            signal=signal,\n            connections=connections,\n            unix=unix,\n        )\n        self.url = None\n        self.request: Optional[Request] = None\n        self.access_log = self.app.config.ACCESS_LOG\n        self.request_handler = self.app.handle_request\n        self.error_handler = self.app.error_handler\n        self.request_timeout = self.app.config.REQUEST_TIMEOUT\n        self.response_timeout = self.app.config.RESPONSE_TIMEOUT\n        self.keep_alive_timeout = self.app.config.KEEP_ALIVE_TIMEOUT\n        self.request_max_size = self.app.config.REQUEST_MAX_SIZE\n        self.request_class = self.app.request_class or Request\n        self.state = state if state else {}\n        if \"requests_count\" not in self.state:\n            self.state[\"requests_count\"] = 0\n        self._exception = None\n\n    def _setup_connection(self):\n        self._http = Http(self)\n        self._time = current_time()\n        self.check_timeouts()\n\n    async def connection_task(self):  # no cov\n        \"\"\"\n        Run a HTTP connection.\n\n        Timeouts and some additional error handling occur here, while most of\n        everything else happens in class Http or in code called from there.\n        \"\"\"\n        try:\n            self._setup_connection()\n            await self.app.dispatch(\n                \"http.lifecycle.begin\",\n                inline=True,\n                context={\"conn_info\": self.conn_info},\n            )\n            await self._http.http1()\n        except CancelledError:\n            pass\n        except Exception:\n            error_logger.exception(\"protocol.connection_task uncaught\")\n        finally:\n            if (\n                self.app.debug\n                and self._http\n                and self.transport\n                and not self._http.upgrade_websocket\n            ):\n                ip = self.transport.get_extra_info(\"peername\")\n                error_logger.error(\n                    \"Connection lost before response written\"\n                    f\" @ {ip} {self._http.request}\"\n                )\n            self._http = None\n            self._task = None\n            try:\n                self.close()\n            except BaseException:\n                error_logger.exception(\"Closing failed\")\n            finally:\n                await self.app.dispatch(\n                    \"http.lifecycle.complete\",\n                    inline=True,\n                    context={\"conn_info\": self.conn_info},\n                )\n                # Important to keep this Ellipsis here for the TouchUp module\n                ...\n\n    def check_timeouts(self):\n        \"\"\"\n        Runs itself periodically to enforce any expired timeouts.\n        \"\"\"\n        try:\n            if not self._task:\n                return\n            duration = current_time() - self._time\n            stage = self._http.stage\n            if stage is Stage.IDLE and duration > self.keep_alive_timeout:\n                logger.debug(\"KeepAlive Timeout. Closing connection.\")\n            elif stage is Stage.REQUEST and duration > self.request_timeout:\n                logger.debug(\"Request Timeout. Closing connection.\")\n                self._http.exception = RequestTimeout(\"Request Timeout\")\n            elif stage is Stage.HANDLER and self._http.upgrade_websocket:\n                logger.debug(\"Handling websocket. Timeouts disabled.\")\n                return\n            elif (\n                stage in (Stage.HANDLER, Stage.RESPONSE, Stage.FAILED)\n                and duration > self.response_timeout\n            ):\n                logger.debug(\"Response Timeout. Closing connection.\")\n                self._http.exception = ServiceUnavailable(\"Response Timeout\")\n            else:\n                interval = (\n                    min(\n                        self.keep_alive_timeout,\n                        self.request_timeout,\n                        self.response_timeout,\n                    )\n                    / 2\n                )\n                self.loop.call_later(max(0.1, interval), self.check_timeouts)\n                return\n            self._task.cancel()\n        except Exception:\n            error_logger.exception(\"protocol.check_timeouts\")\n\n    async def send(self, data):  # no cov\n        \"\"\"\n        Writes HTTP data with backpressure control.\n        \"\"\"\n        await self._can_write.wait()\n        if self.transport.is_closing():\n            raise CancelledError\n        await self.app.dispatch(\n            \"http.lifecycle.send\",\n            inline=True,\n            context={\"data\": data},\n        )\n        self.transport.write(data)\n        self._time = current_time()\n\n    def close_if_idle(self) -> bool:\n        \"\"\"\n        Close the connection if a request is not being sent or received\n\n        :return: boolean - True if closed, false if staying open\n        \"\"\"\n        if self._http is None or self._http.stage is Stage.IDLE:\n            self.close()\n            return True\n        return False\n\n    # -------------------------------------------- #\n    # Only asyncio.Protocol callbacks below this\n    # -------------------------------------------- #\n\n    def connection_made(self, transport):\n        \"\"\"\n        HTTP-protocol-specific new connection handler\n        \"\"\"\n        try:\n            # TODO: Benchmark to find suitable write buffer limits\n            transport.set_write_buffer_limits(low=16384, high=65536)\n            self.connections.add(self)\n            self.transport = transport\n            self._task = self.loop.create_task(self.connection_task())\n            self.recv_buffer = bytearray()\n            self.conn_info = ConnInfo(self.transport, unix=self._unix)\n        except Exception:\n            error_logger.exception(\"protocol.connect_made\")\n\n    def data_received(self, data: bytes):\n\n        try:\n            self._time = current_time()\n            if not data:\n                return self.close()\n            self.recv_buffer += data\n\n            if (\n                len(self.recv_buffer) >= self.app.config.REQUEST_BUFFER_SIZE\n                and self.transport\n            ):\n                self.transport.pause_reading()\n\n            if self._data_received:\n                self._data_received.set()\n        except Exception:\n            error_logger.exception(\"protocol.data_received\")\n", "path": "sanic/server/protocols/http_protocol.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING, Optional\n\nfrom sanic.touchup.meta import TouchUpMeta\n\n\nif TYPE_CHECKING:  # no cov\n    from sanic.app import Sanic\n\nimport sys\n\nfrom asyncio import CancelledError\nfrom time import monotonic as current_time\n\nfrom sanic.exceptions import RequestTimeout, ServiceUnavailable\nfrom sanic.http import Http, Stage\nfrom sanic.log import error_logger, logger\nfrom sanic.models.server_types import ConnInfo\nfrom sanic.request import Request\nfrom sanic.server.protocols.base_protocol import SanicProtocol\n\n\nclass HttpProtocol(SanicProtocol, metaclass=TouchUpMeta):\n    \"\"\"\n    This class provides implements the HTTP 1.1 protocol on top of our\n    Sanic Server transport\n    \"\"\"\n\n    __touchup__ = (\n        \"send\",\n        \"connection_task\",\n    )\n    __slots__ = (\n        # request params\n        \"request\",\n        # request config\n        \"request_handler\",\n        \"request_timeout\",\n        \"response_timeout\",\n        \"keep_alive_timeout\",\n        \"request_max_size\",\n        \"request_class\",\n        \"error_handler\",\n        # enable or disable access log purpose\n        \"access_log\",\n        # connection management\n        \"state\",\n        \"url\",\n        \"_handler_task\",\n        \"_http\",\n        \"_exception\",\n        \"recv_buffer\",\n    )\n\n    def __init__(\n        self,\n        *,\n        loop,\n        app: Sanic,\n        signal=None,\n        connections=None,\n        state=None,\n        unix=None,\n        **kwargs,\n    ):\n        super().__init__(\n            loop=loop,\n            app=app,\n            signal=signal,\n            connections=connections,\n            unix=unix,\n        )\n        self.url = None\n        self.request: Optional[Request] = None\n        self.access_log = self.app.config.ACCESS_LOG\n        self.request_handler = self.app.handle_request\n        self.error_handler = self.app.error_handler\n        self.request_timeout = self.app.config.REQUEST_TIMEOUT\n        self.response_timeout = self.app.config.RESPONSE_TIMEOUT\n        self.keep_alive_timeout = self.app.config.KEEP_ALIVE_TIMEOUT\n        self.request_max_size = self.app.config.REQUEST_MAX_SIZE\n        self.request_class = self.app.request_class or Request\n        self.state = state if state else {}\n        if \"requests_count\" not in self.state:\n            self.state[\"requests_count\"] = 0\n        self._exception = None\n\n    def _setup_connection(self):\n        self._http = Http(self)\n        self._time = current_time()\n        self.check_timeouts()\n\n    async def connection_task(self):  # no cov\n        \"\"\"\n        Run a HTTP connection.\n\n        Timeouts and some additional error handling occur here, while most of\n        everything else happens in class Http or in code called from there.\n        \"\"\"\n        try:\n            self._setup_connection()\n            await self.app.dispatch(\n                \"http.lifecycle.begin\",\n                inline=True,\n                context={\"conn_info\": self.conn_info},\n            )\n            await self._http.http1()\n        except CancelledError:\n            pass\n        except Exception:\n            error_logger.exception(\"protocol.connection_task uncaught\")\n        finally:\n            if (\n                self.app.debug\n                and self._http\n                and self.transport\n                and not self._http.upgrade_websocket\n            ):\n                ip = self.transport.get_extra_info(\"peername\")\n                error_logger.error(\n                    \"Connection lost before response written\"\n                    f\" @ {ip} {self._http.request}\"\n                )\n            self._http = None\n            self._task = None\n            try:\n                self.close()\n            except BaseException:\n                error_logger.exception(\"Closing failed\")\n            finally:\n                await self.app.dispatch(\n                    \"http.lifecycle.complete\",\n                    inline=True,\n                    context={\"conn_info\": self.conn_info},\n                )\n                # Important to keep this Ellipsis here for the TouchUp module\n                ...\n\n    def check_timeouts(self):\n        \"\"\"\n        Runs itself periodically to enforce any expired timeouts.\n        \"\"\"\n        try:\n            if not self._task:\n                return\n            duration = current_time() - self._time\n            stage = self._http.stage\n            if stage is Stage.IDLE and duration > self.keep_alive_timeout:\n                logger.debug(\"KeepAlive Timeout. Closing connection.\")\n            elif stage is Stage.REQUEST and duration > self.request_timeout:\n                logger.debug(\"Request Timeout. Closing connection.\")\n                self._http.exception = RequestTimeout(\"Request Timeout\")\n            elif stage is Stage.HANDLER and self._http.upgrade_websocket:\n                logger.debug(\"Handling websocket. Timeouts disabled.\")\n                return\n            elif (\n                stage in (Stage.HANDLER, Stage.RESPONSE, Stage.FAILED)\n                and duration > self.response_timeout\n            ):\n                logger.debug(\"Response Timeout. Closing connection.\")\n                self._http.exception = ServiceUnavailable(\"Response Timeout\")\n            else:\n                interval = (\n                    min(\n                        self.keep_alive_timeout,\n                        self.request_timeout,\n                        self.response_timeout,\n                    )\n                    / 2\n                )\n                self.loop.call_later(max(0.1, interval), self.check_timeouts)\n                return\n            cancel_msg_args = ()\n            if sys.version_info >= (3, 9):\n                cancel_msg_args = (\"Cancel connection task with a timeout\",)\n            self._task.cancel(*cancel_msg_args)\n        except Exception:\n            error_logger.exception(\"protocol.check_timeouts\")\n\n    async def send(self, data):  # no cov\n        \"\"\"\n        Writes HTTP data with backpressure control.\n        \"\"\"\n        await self._can_write.wait()\n        if self.transport.is_closing():\n            raise CancelledError\n        await self.app.dispatch(\n            \"http.lifecycle.send\",\n            inline=True,\n            context={\"data\": data},\n        )\n        self.transport.write(data)\n        self._time = current_time()\n\n    def close_if_idle(self) -> bool:\n        \"\"\"\n        Close the connection if a request is not being sent or received\n\n        :return: boolean - True if closed, false if staying open\n        \"\"\"\n        if self._http is None or self._http.stage is Stage.IDLE:\n            self.close()\n            return True\n        return False\n\n    # -------------------------------------------- #\n    # Only asyncio.Protocol callbacks below this\n    # -------------------------------------------- #\n\n    def connection_made(self, transport):\n        \"\"\"\n        HTTP-protocol-specific new connection handler\n        \"\"\"\n        try:\n            # TODO: Benchmark to find suitable write buffer limits\n            transport.set_write_buffer_limits(low=16384, high=65536)\n            self.connections.add(self)\n            self.transport = transport\n            self._task = self.loop.create_task(self.connection_task())\n            self.recv_buffer = bytearray()\n            self.conn_info = ConnInfo(self.transport, unix=self._unix)\n        except Exception:\n            error_logger.exception(\"protocol.connect_made\")\n\n    def data_received(self, data: bytes):\n\n        try:\n            self._time = current_time()\n            if not data:\n                return self.close()\n            self.recv_buffer += data\n\n            if (\n                len(self.recv_buffer) >= self.app.config.REQUEST_BUFFER_SIZE\n                and self.transport\n            ):\n                self.transport.pause_reading()\n\n            if self._data_received:\n                self._data_received.set()\n        except Exception:\n            error_logger.exception(\"protocol.data_received\")\n", "path": "sanic/server/protocols/http_protocol.py"}]}