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:
parent
49789b7841
commit
65b53a5f3f
|
@ -8,6 +8,8 @@ from sanic.touchup.meta import TouchUpMeta
|
||||||
if TYPE_CHECKING: # no cov
|
if TYPE_CHECKING: # no cov
|
||||||
from sanic.app import Sanic
|
from sanic.app import Sanic
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from asyncio import CancelledError
|
from asyncio import CancelledError
|
||||||
from time import monotonic as current_time
|
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)
|
self.loop.call_later(max(0.1, interval), self.check_timeouts)
|
||||||
return
|
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:
|
except Exception:
|
||||||
error_logger.exception("protocol.check_timeouts")
|
error_logger.exception("protocol.check_timeouts")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user