MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / create_task

Method create_task

utils/async_utils.py:235–253  ·  view source on GitHub ↗

Create and track a task that will run in the pool. Args: coro: The coroutine function to create a task for. *args: Positional arguments for the coroutine. **kwargs: Keyword arguments for the coroutine. Returns: The created as

(self, coro: Callable, *args: Any, **kwargs: Any)

Source from the content-addressed store, hash-verified

233 return await coro(*args, **kwargs)
234
235 def create_task(self, coro: Callable, *args: Any, **kwargs: Any) -> asyncio.Task:
236 """
237 Create and track a task that will run in the pool.
238
239 Args:
240 coro: The coroutine function to create a task for.
241 *args: Positional arguments for the coroutine.
242 **kwargs: Keyword arguments for the coroutine.
243
244 Returns:
245 The created asyncio.Task object.
246 """
247 # Create a task that runs the coroutine through the pool's 'run' method
248 task = asyncio.create_task(self.run(coro, *args, **kwargs))
249 # Add the task to the tracking list
250 self.tasks.append(task)
251 # Add a callback to automatically remove the task from the list when it's done
252 task.add_done_callback(lambda t: self.tasks.remove(t))
253 return task
254
255 async def wait_all(self) -> None:
256 """Wait for all currently tracked tasks in the pool to complete."""

Callers 1

evaluate_multipleMethod · 0.80

Calls 1

runMethod · 0.95

Tested by

no test coverage detected