MCPcopy
hub / github.com/InternLM/lmdeploy / cancel_async_tasks

Function cancel_async_tasks

lmdeploy/pytorch/utils.py:223–231  ·  view source on GitHub ↗

Cancel async tasks.

(tasks: Sequence[asyncio.Task])

Source from the content-addressed store, hash-verified

221
222
223async def cancel_async_tasks(tasks: Sequence[asyncio.Task]):
224 """Cancel async tasks."""
225 if isinstance(tasks, asyncio.Task):
226 tasks = [tasks]
227
228 tasks = list(task for task in tasks if not task.done())
229 for task in tasks:
230 task.cancel()
231 return await asyncio.gather(*tasks, return_exceptions=True)

Callers 1

wait_tasksMethod · 0.90

Calls 2

doneMethod · 0.80
cancelMethod · 0.45

Tested by

no test coverage detected