Name | aiosqs JSON |
Version |
1.0.5
JSON |
| download |
home_page | None |
Summary | Python asynchronous and lightweight SQS client. |
upload_time | 2024-01-13 09:06:15 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
aws
sqs
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## aiosqs
[![pypi](https://img.shields.io/pypi/v/aiosqs.svg)](https://pypi.org/project/aiosqs/)
Python asynchronous and lightweight SQS client. The goal of this library is to provide fast and optimal access to SQS
for Python projects, e.g. when you need a high-load queue consumer or high-load queue producer written in Python.
Supports Python versions 3.8, 3.9, 3.10, 3.11, 3.12.
Supported and tested Amazon-like SQS providers: Amazon, VK Cloud.
----
## Why aiosqs?
Main problem of `botocore` and `aiobotocore` is huge memory and CPU consumption.
Also `aiobotocore` itself is a transition of `botocore` to async interface without any optimizations.
Related issues:
- https://github.com/boto/boto3/issues/1670
- https://github.com/aio-libs/aiobotocore/issues/940
- https://github.com/aio-libs/aiobotocore/issues/970
## Installation
Install package:
```shell
pip install aiosqs
```
## Usage
Create a client:
```python
from aiosqs import SQSClient
client = SQSClient(
aws_access_key_id="access_key_id",
aws_secret_access_key="secret_access_key",
region_name="us-west-2",
host="sqs.us-west-2.amazonaws.com",
)
```
Receive the queue url by queue name:
```python
response = await client.get_queue_url(queue_name=queue_name)
queue_url = response["QueueUrl"]
```
Send a message to the queue:
```python
response = await client.send_message(
queue_url=queue_url,
message_body=json.dumps({"demo": 1, "key": "value"}),
delay_seconds=0,
)
print(response)
```
Receive a message from the queue:
```python
response = await client.receive_message(
queue_url=queue_url,
max_number_of_messages=1,
visibility_timeout=30,
)
if response:
print(response)
receipt_handle = response[0]["ReceiptHandle"]
```
Delete the message from the queue:
```python
await client.delete_message(
queue_url=queue_url,
receipt_handle=receipt_handle,
)
```
Close the client at the end:
```python
await client.close()
```
Another option is to use `SQSClient` as an async context manager. No need to call `close` manually in this case. Example:
```python
from aiosqs import SQSClient
async with SQSClient(
aws_access_key_id="access_key_id",
aws_secret_access_key="secret_access_key",
region_name="us-west-2",
host="sqs.us-west-2.amazonaws.com",
) as client:
response = await client.get_queue_url(queue_name="dev_orders")
queue_url = response["QueueUrl"]
print(queue_url)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "aiosqs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "aws,sqs",
"author": null,
"author_email": "Vladimir Kasatkin <vladimirkasatkinbackend@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/05/93/3d49ec7a7c8ce2e0310ab2e8340cef71fd5527346ac595603ef346b35300/aiosqs-1.0.5.tar.gz",
"platform": null,
"description": "## aiosqs\n\n[![pypi](https://img.shields.io/pypi/v/aiosqs.svg)](https://pypi.org/project/aiosqs/)\n\nPython asynchronous and lightweight SQS client. The goal of this library is to provide fast and optimal access to SQS \nfor Python projects, e.g. when you need a high-load queue consumer or high-load queue producer written in Python.\n\nSupports Python versions 3.8, 3.9, 3.10, 3.11, 3.12.\n\nSupported and tested Amazon-like SQS providers: Amazon, VK Cloud.\n\n----\n\n## Why aiosqs?\n\nMain problem of `botocore` and `aiobotocore` is huge memory and CPU consumption.\nAlso `aiobotocore` itself is a transition of `botocore` to async interface without any optimizations.\n\nRelated issues:\n- https://github.com/boto/boto3/issues/1670\n- https://github.com/aio-libs/aiobotocore/issues/940\n- https://github.com/aio-libs/aiobotocore/issues/970\n\n\n## Installation\n\nInstall package:\n```shell\npip install aiosqs\n```\n\n\n## Usage\n\nCreate a client:\n```python\nfrom aiosqs import SQSClient\n\nclient = SQSClient(\n aws_access_key_id=\"access_key_id\",\n aws_secret_access_key=\"secret_access_key\",\n region_name=\"us-west-2\",\n host=\"sqs.us-west-2.amazonaws.com\",\n)\n```\n\nReceive the queue url by queue name:\n```python\nresponse = await client.get_queue_url(queue_name=queue_name)\nqueue_url = response[\"QueueUrl\"]\n```\n\nSend a message to the queue:\n```python\nresponse = await client.send_message(\n queue_url=queue_url,\n message_body=json.dumps({\"demo\": 1, \"key\": \"value\"}),\n delay_seconds=0,\n)\nprint(response)\n```\n\nReceive a message from the queue:\n```python\nresponse = await client.receive_message(\n queue_url=queue_url,\n max_number_of_messages=1,\n visibility_timeout=30,\n)\nif response:\n print(response)\n receipt_handle = response[0][\"ReceiptHandle\"]\n```\n\nDelete the message from the queue:\n```python\nawait client.delete_message(\n queue_url=queue_url,\n receipt_handle=receipt_handle,\n)\n```\n\nClose the client at the end:\n```python\nawait client.close()\n```\n\nAnother option is to use `SQSClient` as an async context manager. No need to call `close` manually in this case. Example:\n```python\nfrom aiosqs import SQSClient\n\nasync with SQSClient(\n aws_access_key_id=\"access_key_id\",\n aws_secret_access_key=\"secret_access_key\",\n region_name=\"us-west-2\",\n host=\"sqs.us-west-2.amazonaws.com\",\n) as client:\n response = await client.get_queue_url(queue_name=\"dev_orders\")\n queue_url = response[\"QueueUrl\"]\n print(queue_url)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Python asynchronous and lightweight SQS client.",
"version": "1.0.5",
"project_urls": {
"Homepage": "https://github.com/d3QUone/aiosqs",
"Source": "https://github.com/d3QUone/aiosqs",
"Tracker": "https://github.com/d3QUone/aiosqs/issues"
},
"split_keywords": [
"aws",
"sqs"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3e7103aee8259fbb4fddc293e0176f4d1c897cf4a47f1fcbc3f45853638b4350",
"md5": "f8de9083f645752d61a6d88b09fb0a63",
"sha256": "45e66436ca34b259551131a9c96531e89ffa3ffbd2cfd8c9bf04633368f4775e"
},
"downloads": -1,
"filename": "aiosqs-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f8de9083f645752d61a6d88b09fb0a63",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 19212,
"upload_time": "2024-01-13T09:06:17",
"upload_time_iso_8601": "2024-01-13T09:06:17.693787Z",
"url": "https://files.pythonhosted.org/packages/3e/71/03aee8259fbb4fddc293e0176f4d1c897cf4a47f1fcbc3f45853638b4350/aiosqs-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "05933d49ec7a7c8ce2e0310ab2e8340cef71fd5527346ac595603ef346b35300",
"md5": "8bd340d08b58141f562c0b420a3c6c62",
"sha256": "7d5d7d93e96b7226592356883fb460e139bd525236aa9cb79e8add0037544f96"
},
"downloads": -1,
"filename": "aiosqs-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "8bd340d08b58141f562c0b420a3c6c62",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 49134,
"upload_time": "2024-01-13T09:06:15",
"upload_time_iso_8601": "2024-01-13T09:06:15.917866Z",
"url": "https://files.pythonhosted.org/packages/05/93/3d49ec7a7c8ce2e0310ab2e8340cef71fd5527346ac595603ef346b35300/aiosqs-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-13 09:06:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "d3QUone",
"github_project": "aiosqs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aiosqs"
}