File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
packages/common-library/src/common_library Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -89,15 +89,26 @@ async def cancel_wait_task(
8989 TimeoutError: raised if cannot cancel the task.
9090 CancelledError: raised ONLY if owner is being cancelled.
9191 """
92+ if task .done ():
93+ # nothing to do here
94+ return
95+
96+ # mark for cancellation
9297 task .cancel ("cancel_wait_task was called to cancel this task" )
9398 try :
94- _logger .debug ("%s" , f"Cancelling task { task .get_name ()!r } " )
99+ _logger .debug ("Cancelling task %s" , task .get_name ())
95100 await asyncio .shield (
96101 # NOTE shield ensures that cancellation of the caller function won't stop you
97102 # from observing the cancellation/finalization of task.
98103 asyncio .wait_for (task , timeout = max_delay )
99104 )
100-
105+ except TimeoutError :
106+ _logger .exception (
107+ "Timeout while cancelling task %s after %s seconds" ,
108+ task .get_name (),
109+ max_delay ,
110+ )
111+ raise
101112 except asyncio .CancelledError :
102113 current_task = asyncio .current_task ()
103114 assert current_task is not None # nosec
@@ -108,7 +119,7 @@ async def cancel_wait_task(
108119 if not task .done ():
109120 _logger .error ("Failed to cancel %s" , task .get_name ())
110121 else :
111- _logger .debug ("%s " , f"Task { task .get_name ()!r } cancelled" )
122+ _logger .debug ("Task %s cancelled " , task .get_name ())
112123
113124
114125def delayed_start (
You can’t perform that action at this time.
0 commit comments