style: add msg in `task.cancel` (#2416)

* 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>
This commit is contained in:
Ryu Juheon 2022-06-16 16:55:20 +09:00 committed by GitHub
parent 49789b7841
commit 65b53a5f3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,8 @@ from sanic.touchup.meta import TouchUpMeta
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 @@ class HttpProtocol(SanicProtocol, metaclass=TouchUpMeta):
)
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")