Skip to content

Commit

Permalink
style: add msg in task.cancel (#2416)
Browse files Browse the repository at this point in the history
* style: add msg in ``task.cancel``

* style: apply isort

* fix: use else statement

* fix: use tuple

* fix: rollback for test

* fix: rollback like previous change

* fix: add ``=``

Co-authored-by: Adam Hopkins <adam@amhopkins.com>
  • Loading branch information
SaidBySolo and ahopkins committed Jun 16, 2022
1 parent 49789b7 commit 65b53a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sanic/server/protocols/http_protocol.py
Expand Up @@ -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

Expand Down Expand Up @@ -169,7 +171,10 @@ def check_timeouts(self):
)
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")

Expand Down

0 comments on commit 65b53a5

Please sign in to comment.