You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def_on_timeout(self, task: "asyncio.Task[None]") ->None:
task.cancel(msg="timeout") # <--- add the reason of cancellationself._state=_State.TIMEOUT# drop the reference earlyself._timeout_handler=None
This would be useful to distinguish the reason of cancellation in library's user programs.
The text was updated successfully, but these errors were encountered:
class CustomTask(asyncio.Task):
def cancel(self, msg=None):
self._msg = msg
super().cancel()
def _on_timeout(self, task: "asyncio.Task[None]") -> None:
task.cancel(msg="timeout") # Adding a custom reason for cancellation
self._state = _State.TIMEOUT
# Drop the reference early
self._timeout_handler = None
Replace asyncio.Task with CustomTask wherever you want to use it
How about adding
msg
argument totask.cancel()
?TL;DR:
This would be useful to distinguish the reason of cancellation in library's user programs.
The text was updated successfully, but these errors were encountered: