# AsyncQueue
## Overview
AsyncQueue is a Python library designed to manage and execute tasks concurrently using asyncio.
It supports task prioritization, robust error handling, and efficient queue management for both finite
and infinite task processing modes.
---
## Features
- **QueueItem**:
- Represents individual tasks with arguments and prioritization support.
- Supports both synchronous and asynchronous task execution.
- **TaskQueue**:
- Manages tasks with configurable workers and prioritization.
- Modes:
- `finite`: Process tasks and stop.
- `infinite`: Continuously process tasks until stopped.
- Handles graceful shutdowns, including signal handling (e.g., SIGINT).
---
## Installation
Ensure you have Python 3.10+ installed.
```bash
pip install async-queue-manager
```
## Usage
### Example
```python
import asyncio
from async_queue.task_queue import TaskQueue
from async_queue.queue_item import QueueItem
async def my_task(name, duration):
print(f"{name} is starting...")
await asyncio.sleep(duration)
print(f"{name} is finished.")
async def main():
queue = TaskQueue(workers=3, mode='finite')
# Add tasks
for i in range(5):
task = QueueItem(my_task, name=f"Task-{i}", duration=2)
queue.add(item=task, priority=i)
# Run the queue
await queue.run(timeout=10)
# Run the program
asyncio.run(main())
```
---
## Project Structure
- **`queue_item.py`**: Implements the `QueueItem` class.
- **`task_queue.py`**: Contains the `TaskQueue` class for task management.
---
## Contributions
Contributions are welcome!
- Report bugs or issues.
- Submit feature requests or enhancements via pull requests.
---
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
```
Raw data
{
"_id": null,
"home_page": null,
"name": "async-queue-manager",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "asynchronous, async task queue, concurrency, asyncio",
"author": null,
"author_email": "Ichinga Samuel <ichingasamuel@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/91/8c/8df1d3db7eac996c7d7a8a035c9ad63ab7465b8c292de9c3fd8e250f9acf/async_queue_manager-2.0.0.tar.gz",
"platform": null,
"description": "# AsyncQueue\r\n\r\n## Overview\r\n\r\nAsyncQueue is a Python library designed to manage and execute tasks concurrently using asyncio. \r\nIt supports task prioritization, robust error handling, and efficient queue management for both finite \r\nand infinite task processing modes.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- **QueueItem**:\r\n - Represents individual tasks with arguments and prioritization support.\r\n - Supports both synchronous and asynchronous task execution.\r\n\r\n- **TaskQueue**:\r\n - Manages tasks with configurable workers and prioritization.\r\n - Modes:\r\n - `finite`: Process tasks and stop.\r\n - `infinite`: Continuously process tasks until stopped.\r\n - Handles graceful shutdowns, including signal handling (e.g., SIGINT).\r\n\r\n---\r\n\r\n## Installation\r\n\r\nEnsure you have Python 3.10+ installed.\r\n\r\n```bash\r\npip install async-queue-manager \r\n```\r\n\r\n## Usage\r\n\r\n### Example\r\n\r\n```python\r\nimport asyncio\r\nfrom async_queue.task_queue import TaskQueue\r\nfrom async_queue.queue_item import QueueItem\r\n\r\nasync def my_task(name, duration):\r\n print(f\"{name} is starting...\")\r\n await asyncio.sleep(duration)\r\n print(f\"{name} is finished.\")\r\n\r\nasync def main():\r\n queue = TaskQueue(workers=3, mode='finite')\r\n\r\n # Add tasks\r\n for i in range(5):\r\n task = QueueItem(my_task, name=f\"Task-{i}\", duration=2)\r\n queue.add(item=task, priority=i)\r\n\r\n # Run the queue\r\n await queue.run(timeout=10)\r\n\r\n# Run the program\r\nasyncio.run(main())\r\n```\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n- **`queue_item.py`**: Implements the `QueueItem` class.\r\n- **`task_queue.py`**: Contains the `TaskQueue` class for task management.\r\n\r\n---\r\n\r\n## Contributions\r\n\r\nContributions are welcome!\r\n\r\n- Report bugs or issues.\r\n- Submit feature requests or enhancements via pull requests.\r\n\r\n---\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Asynchronous Task Queue",
"version": "2.0.0",
"project_urls": {
"Bug Tracker": "https://github.com/Ichinga-Samuel/taskqueue/issues",
"Homepage": "https://github.com/Ichinga-Samuel/taskqueue"
},
"split_keywords": [
"asynchronous",
" async task queue",
" concurrency",
" asyncio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "793ae4cc39c8d549f4bf76a59df98edf0510e0a5314540559d7e17a626f1bbe9",
"md5": "2c185d9ce5f2e39cf7650a3fb7e6ff80",
"sha256": "1293e1c182181f10666801660ef6edea30652affe20daae21254aa52a8ee5029"
},
"downloads": -1,
"filename": "async_queue_manager-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2c185d9ce5f2e39cf7650a3fb7e6ff80",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 6147,
"upload_time": "2024-12-15T21:49:27",
"upload_time_iso_8601": "2024-12-15T21:49:27.469784Z",
"url": "https://files.pythonhosted.org/packages/79/3a/e4cc39c8d549f4bf76a59df98edf0510e0a5314540559d7e17a626f1bbe9/async_queue_manager-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "918c8df1d3db7eac996c7d7a8a035c9ad63ab7465b8c292de9c3fd8e250f9acf",
"md5": "8c5f562942ed4a6a554e5615ebbbd180",
"sha256": "7e6d612290b34ee9cfc2c74f3d8c614f94a04ee85af1133e0abb24b75a9d47af"
},
"downloads": -1,
"filename": "async_queue_manager-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "8c5f562942ed4a6a554e5615ebbbd180",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 6561,
"upload_time": "2024-12-15T21:49:30",
"upload_time_iso_8601": "2024-12-15T21:49:30.674488Z",
"url": "https://files.pythonhosted.org/packages/91/8c/8df1d3db7eac996c7d7a8a035c9ad63ab7465b8c292de9c3fd8e250f9acf/async_queue_manager-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-15 21:49:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Ichinga-Samuel",
"github_project": "taskqueue",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "async-queue-manager"
}