# 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(queue_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/81/e3/f6757fa38652d9b345f5a8e46799a695249815e84343cebe6ebce64c48a8/async_queue_manager-3.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(queue_timeout=10)\r\n\r\n# Run the program\r\nasyncio.run(main())\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": "3.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": "5c118247b9420641d04a490ab8a7d0d7986be4417953bc3e50b2ba052a149a96",
"md5": "5d882f923cc5c547c3e15b2c0e01e643",
"sha256": "dcf5871a8f953436a74646bde3b087ceb3ec9d720f6467db509976c32ff48eaa"
},
"downloads": -1,
"filename": "async_queue_manager-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5d882f923cc5c547c3e15b2c0e01e643",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 6438,
"upload_time": "2025-01-11T18:45:32",
"upload_time_iso_8601": "2025-01-11T18:45:32.331492Z",
"url": "https://files.pythonhosted.org/packages/5c/11/8247b9420641d04a490ab8a7d0d7986be4417953bc3e50b2ba052a149a96/async_queue_manager-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "81e3f6757fa38652d9b345f5a8e46799a695249815e84343cebe6ebce64c48a8",
"md5": "6108b02a48b7520c45646ee36255a311",
"sha256": "08c656653dd42c58f028c83fdc4f54c136f8e61967b49903fb0514c6eac4dc7d"
},
"downloads": -1,
"filename": "async_queue_manager-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "6108b02a48b7520c45646ee36255a311",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 7386,
"upload_time": "2025-01-11T18:45:35",
"upload_time_iso_8601": "2025-01-11T18:45:35.058351Z",
"url": "https://files.pythonhosted.org/packages/81/e3/f6757fa38652d9b345f5a8e46799a695249815e84343cebe6ebce64c48a8/async_queue_manager-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-11 18:45:35",
"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"
}