TaskPool Module Design Document
Overview
The TaskPool module is an asynchronous task management component that controls task concurrency through a semaphore mechanism and supports automatic task lifecycle management.
Initialization Parameters
| Parameter Name | Type/Optional | Description |
|---|---|---|
| max_concurrency | int (Optional) | The maximum number of concurrent tasks, defaults to 4 |
Class Method Descriptions
create_task(coro_func, *args, **kwargs)
Creates and starts an asynchronous task.
Parameters
- coro_func: The coroutine function to be executed
- *args: Positional arguments
- **kwargs: Keyword arguments
Return Value
- asyncio.Task: The created task object
wait_all()
Waits for all tasks to complete and returns a list of results.
Return Value
- List[Any]: A list of task execution results